Exporting data to CSV with French characters in ASP.Net

by Joe Payne 12. September 2012 08:57

For the longest time, I’ve used a nifty little export routine that takes any DataTable and pushes it to the browser as a CSV file.  This makes it extremely easy to incorporate an Export to Excel feature into any custom report.

An international client recently requested support for French accent characters.  This was new to me, I didn’t even realize it wasn’t working.   I try to stick with knowing one language at a time Smile

Apparently the necessary encoding is implemented in the web page by default.  That’s why it looks ok in the browser.  But when the CSV is being streamed to the browser for download as a file, the encoding does not default to the same.

The fix was easy enough:

Response.ContentEncoding = System.Text.Encoding.UTF8; 
Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble()); 

 

*POW* Now the CSV has the proper characters for French accent letters.

Tags: , , ,

Personal | AC7 Articles

Exporting CSV files in Excel 2007

by Joe Payne 28. Januarie 2008 00:14
I used the email lists export (thank you Able for having that feature) to migrate my subscribed users to my list server. The problem was the list server requires quote delimiters and the AC7 file doesn't have them.

I thought Excel could do it by opening and resaving the CSV file. No-go, it's a common problem in Excel 2007 apparently.

Microsoft wrote a nice little VBA.Excel app to do it for you. Here's the link with instructions and the code.

http://support.microsoft.com/kb/291296/en-us

Enjoy!

Tags: , ,

AC7 Articles

Month List