You need to sign in to do that
Don't have an account?
Anand@SAAS
Save to CSV/Excel in visual force with UTF 8 chracters
I'm trying to create visual force page that downloads as Excel or CSV . This works fine for English but for UTF 8 characters like Polish etc. some of the characters get replaced with "?" etc. I'm not sure there's a way to specify encoding when using contentTypes.
This worked for me:
Trick is showheaders="false" and insert your own HTML <head> tag with the character encoding you are emitting. Otherwise, the default, at least for me in the US, was ISO 8859-1 which will not display UTF-8 characters above codepoint 7F successfully - limiting you to A-Z, a-z, 0-9, and common US/UK punctuation. My inspiration for this was here.
Tested on IE8, Firefox, Chrome.
Excel appears to coerce the font to Arial Unicode MS 10pt which is a good font for UTF-8.
All Answers
check out the contentType attribute for apex:page
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_compref_page.htm
The issue is that when you use application.vnd-excel, and the page has some UTF-8 characters (polish, hungarian etc.) and the downloaded excel doe'snt render the characters correctly.
I suppose the problem could be Excel. Maybe it does not evaluate the content type of the html page (because that is what it is).
I guess you can check by saving the file to disk, then from an Excel window, open or import the html file. I think the import lets you specify the character encoding. If it then displays the data correctly, it ignores the encoding when you open it directly.
Also check the font you are using, try changing it to the Arial UTF font
This worked for me:
Trick is showheaders="false" and insert your own HTML <head> tag with the character encoding you are emitting. Otherwise, the default, at least for me in the US, was ISO 8859-1 which will not display UTF-8 characters above codepoint 7F successfully - limiting you to A-Z, a-z, 0-9, and common US/UK punctuation. My inspiration for this was here.
Tested on IE8, Firefox, Chrome.
Excel appears to coerce the font to Arial Unicode MS 10pt which is a good font for UTF-8.
Eric..excellent suggestion. The "Meta" tag in the document seems to be doing the trick.
Hi guys,
I tried the following code. The resulting excel sheet only contains the header, but not the contact names... What am I doing wrong?
Thank you,
Josh :-)
My bad. I fixed it.
Hi Guys,
I have tried the Above code. its fine for few datas, but I am having 1000+ Records including 35 Colomns.I unable to export the Data to excel, Data is exported but unable to read, When i was trying to read the exported excel file its showing message that "Unable to read file". but in 2010v of Excel its working fine but 2003 its showing this error message.due to lots of data.
Please any body suggest me how can i solve this problem in 2003v of Excel
Thanks & Regards
Bijay Kumar