Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion XLS "Export" and Character Encoding

I am "exporting" data from a page to Excel using an HTML table. The table looks fine in the browser but in Excel special characters such as apostrophes, trademark symbols, etc. are improperly encoded. If I open the exported file in notepad and save it as ANSII encoded then open it in Excel everything looks fine again.

I tried setting the page encoding in ColdFusion using cfcontent, setencoding, and cfpagedirective with no luck so far. Any suggestions?

EDIT: As a temporary work around, the erroneous characters can be removed by saving the exported file to disk, opening it in Notepad, and then saving it again. Not exactly the best solution for the problem.

As for the strange characters:

® becomes ®

™ becomes â„¢

’ becomes ’

like image 750
illvm Avatar asked Nov 26 '25 17:11

illvm


1 Answers

I ran into the same problem with the strange character 'Â' showing up in my Excel spreadsheet when it wasn't there in my HTML page which it came from.

Simply changing the cfcontent from: <cfcontent type="application/vnd.ms-excel> to: <cfcontent type="application/vnd.ms-excel; charset=windows-1252"> fixed the issue for me.

like image 67
Spoony Avatar answered Nov 30 '25 21:11

Spoony