Current location: Hot Scripts Forums » Programming Languages » ASP » When I used "application/vnd.ms-excel" to export table's content to Excel file. It wo


When I used "application/vnd.ms-excel" to export table's content to Excel file. It wo

Closed Thread
  #1 (permalink)  
Old 01-28-05, 03:16 PM
miaomiaoga miaomiaoga is offline
New Member
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Angry When I used "application/vnd.ms-excel" to export table's content to Excel file. It wo

Hi,All,

Export Method:
-------------------------------------------------------------------------
asp Code:
  1. strFileNameExport = "Results"
  2.  
  3. Response.Clear()
  4. Response.Buffer  =  True
  5. Response.ContentType ="application/vnd.ms-excel" 'application/msword
  6. Response.Addheader "Content-Disposition", "attachment;Filename=" &
  7. strFileNameExport & ".xls"
  8. Response.Charset = "GB2312"
  9. Response.Codepage = "936"
  10. tblHeader = "<html><body><table border=1>"
  11. tblFooter = "</table></body></html>"
  12. Response.Write tblHeader & strContent & tblFooter
---------------------------------------------------------------------

I used this code to export the content of table to Excel File. But when i
opened the Excel file, sometime the words of the content would be showed as
"confused" words. But so strange the same table (same content), sometimes
would be "confused". And sometimes it would be showed normally. It's
randomly between "confused" words and normally words.

And I had tried to change all Charset and Codepage setting of all pages. But
same result.

Seems this problem not related with Charset and Codepage setting.


(All words showed "confused" is Chinese words. And english words all are
normally. Randomly showed this error sympton in Excel file.)

Environment: ASP,SQL2K,WIN2003.


--


Benny Ng

Last edited by Nico; 08-02-07 at 09:52 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #2 (permalink)  
Old 08-02-07, 09:40 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
Hi miaomiaoga,


You might wanna try the solution that i posted here:

http://www.opcg.com/index.php?blog=2&p=45

It comes down to using the BinaryWrite method instead of the Write method of the Response.

Regards,


Yeroon
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #3 (permalink)  
Old 08-02-07, 09:53 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Please don't bump 2 year old threads. Thanks.



Closed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
webpage export to a PDF or Excel File jtmoore73 HTML/XHTML/XML 1 09-24-04 02:15 PM
Error On Registeration timmy408 ASP 2 09-05-04 03:53 PM
Export to excel file asp traceMe ASP 2 08-01-04 10:07 PM
Excel document containing records, need to save as a text file to upload to mysql bearslife PHP 1 06-05-04 04:24 AM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 05:28 PM


All times are GMT -5. The time now is 11:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.