CSV incorrect file name when opened from web MSIE6.0

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


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

..CSV]Data_Export3732(1)



Thanks for any guide...
 
B

Bob Buckland ?:-\)

Hi Gustavo,

You may want to use the link below to post this in the MS Excel newsgroup. When posting there you may want to include the version
of Excel and Windows you're testing with.

================
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


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

..CSV]Data_Export3732(1)



Thanks for any guide... >>
--
Please let us know if this has helped,

Bob Buckland ?:)
MS Office System Products MVP

LINKS
A. Specific newsgroup/discussion group mentioned in this message:
news://msnews.microsoft.com/microsoft.public.excel
or via browser:
http://microsoft.com/communities/newsgroups/en-us/?dg=microsoft.public.excel

B. MS Office Community discussion/newsgroups via Web Browser
http://microsoft.com/office/community/en-us/default.mspx
or
Microsoft hosted newsgroups via Outlook Express/newsreader
news://msnews.microsoft.com
 

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