R
roel.schreurs
I am offering visitors of a website the possibilty to download a csv
formatted file of data. Visitors may normally choose to save the
download or to open it directly with Excel.
I have noticed that if they choose to open it, the Worksheet will have
a name containing brackets, which is considered invalid by Excel and
this prevents users to:
1) rename the woksheet
2) use the data in the sheet for reference form other sheets, for pivot
tables, e.t.c.
If the file is suqsequently saved, the worksheet is renamed and all
works fine.
Below is a sample that reproduces the behaviour:
1. Start VS.NET and create a new VB.NET Web Application.
2. On the aspx page, place an button named Download.
3. Double click the button and modify the event handler to look as
follows:
Private Sub Download_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Download.Click
Response.Clear()
'Indicated by Q260519 http://support.microsoft.com/kb/q260519/
Response.AddHeader("content-disposition",
"attachment;filename=test.csv")
Response.ContentType = "text/csv"
Response.Write("These;are;some;cells")
Response.End()
End Sub
(Note the comment about Q260519)
4. Run the application and click the Download button.
5. Choose Open with Excel.
The worksheet that is opened will be named .csv]test(1)
Notes:
1. The problem only occurs with IE. It appears that the downloaded
files are stored in a location like:
C:\Documents and Settings\<account>\Local Settings\Temporary Internet
Files\<B4645LS9>
2. Downloads using Firefox do not show this problem.
Of course, I could notify visitors about this problem, but I would
really like a solution. Does anybody have it?
formatted file of data. Visitors may normally choose to save the
download or to open it directly with Excel.
I have noticed that if they choose to open it, the Worksheet will have
a name containing brackets, which is considered invalid by Excel and
this prevents users to:
1) rename the woksheet
2) use the data in the sheet for reference form other sheets, for pivot
tables, e.t.c.
If the file is suqsequently saved, the worksheet is renamed and all
works fine.
Below is a sample that reproduces the behaviour:
1. Start VS.NET and create a new VB.NET Web Application.
2. On the aspx page, place an button named Download.
3. Double click the button and modify the event handler to look as
follows:
Private Sub Download_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Download.Click
Response.Clear()
'Indicated by Q260519 http://support.microsoft.com/kb/q260519/
Response.AddHeader("content-disposition",
"attachment;filename=test.csv")
Response.ContentType = "text/csv"
Response.Write("These;are;some;cells")
Response.End()
End Sub
(Note the comment about Q260519)
4. Run the application and click the Download button.
5. Choose Open with Excel.
The worksheet that is opened will be named .csv]test(1)
Notes:
1. The problem only occurs with IE. It appears that the downloaded
files are stored in a location like:
C:\Documents and Settings\<account>\Local Settings\Temporary Internet
Files\<B4645LS9>
2. Downloads using Firefox do not show this problem.
Of course, I could notify visitors about this problem, but I would
really like a solution. Does anybody have it?