CSV incorrect worksheet name when downloaded from web MSIE6

G

Gustavo Ortega

Hello,

When I use the follwing aspx code to get a csv file via Internet Explorer in
MS Excel, after comfirm dialog box as "Open content immediately" Excel
displays a corrupt worksheet name as given in:


Response.Buffer = True
Response.ClearContent()
Response.ClearHeaders()
Response.Charset = ""

....

Response.AppendHeader("content-length", reportOutput.Length.ToString())
Dim type As String = Request.QueryString("Type")
Dim strFileName As String = Request.Params("FileName")

....
Response.ContentType = "application/csv"
Response.AddHeader("Content-Disposition",
String.Format("attachment;filename={0}.CSV ", strFileName))

....

Response.AddHeader("Content-Transfer-Encoding", "binary")
Response.BinaryWrite(reportOutput)
Response.Flush()
Response.End()


then the CSV file opens as:

'.CSV]fille_name[1]'

This worksheet name cannot even be edited to eg. 'table_1'. Excel does not
accept any typing, complaining "wrong characters".

If I write the file to disk instead of opening it in Excel, everything works
fine when I try to open the saved file afterwards.

I don't have a clue on this... however the HTTP headed looks to come back
correctly from the server:

HTTP/1.1 200 OK
Date: Thu, 09 Nov 2006 17:01:31 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
X-AspNet-Version: 2.0.50727
Content-Length: 7092
Content-Disposition: attachment;filename=Data_Export3732.CSV
Content-Transfer-Encoding: binary
Cache-Control: private
Content-Type: application/vnd.ms-excel

Environment:
Server: Windows 2003 Enterprise Server
Client: Windows XP Pro, Windows Server 2003 Server. Using Microsoft Office
2003.


Following the example from this header... the worksheet name will open as
follows in Excel:

..CSV]Data_Export3732(1)



Thanks for any guide...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top