Hello Rick,
Thank you for the prompt reply. I have received your email. According to
the picture "ReportPage_ShowAsHtml.JPG", Excel is showing the html source
of a web page. Would you help to check what web page is that for? Is it the
page where you click on the download button? (But it is strange that I
cannot find the button's html tag according to the screen shot.) In the
meantime, can you access the csv file located on the server? Would you help
to open it directly on server and see whether the csv's content is correct?
Is it possible that the csv file on the server has been overwritten
unexpectedly?
In order to test whether a csv file could be shown correctly in the
browser, I did the following test on a Window 2003 Server system, with .NET
2.0, Visual Studio 2005, and Office 2003 Enterprise (SP2). I have attached
the complete test web project and the test csv file to this reply. (You
could download the attachment with Outlook Express or Windows Mail). The
test project worked as expected in my side.
In the test project, I created a simple VB.NET web application with Visual
Studio 2005. There is only on button <asp:Button ID="Button1"
runat="server" Onclick="Button1_Click" Text="Download" /> in the
Default.aspx page. In Button1_Click event handler, I paste your code there:
Dim resp As HttpResponse
Dim reportfilenamehere As String = "Book1.csv"
resp = Page.Response
resp.Clear()
resp.ContentType = "application/vnd.ms-excel"
resp.AppendHeader("Content-Disposition", "attachment;filename=" &
reportfilenamehere)
resp.WriteFile(reportfilenamehere)
resp.Flush()
resp.End()
Book1.csv is located in the same directory as Default.aspx, and it only
contains two lines of data:
1,1,1,1
2,2,2,2
When I run the project and clicks on the "download" button, the csv is
downloaded and shown correctly. I also tested to publish the web
application to another Windows 2003 server system, then visit the site, I
am still not able to reproduce the issue in my side. Would you please check
the points I mentioned in the beginning of the reply and let me know the
result? I am looking forward to your reply.
I understand that we didn't make much progress on this issue so far. It's
mainly because it's not reproducible in my side and yours and it is not
convenient to do the tests directly. Although troubleshooting such issues
in newsgroup might not be the best channel, I will try my best to help.
Sincerely,
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.