I have a problem similar to this question. That is - I need to export some UTF8 data within a MySQL database to MS Excel.
The gotchas kindly Excel provides:
- Excel opens UTF8 formatted CSV files as ANSCI, thus breaking
- Excel will open tab-seperated UTF8 files correctly, but there is no support for linebreaks (my data has linebreaks, though in a worst-case scenario I might be able to loose these)
- Excel will, apparently, open UTF-16LE (little endian) encoded CSVs OK. However, so far as I know, MySQL INTO OUTFILE does not accept content encoding argument, and just defaults to the database encoding (UTF8).
My web-app is PHP driven, but unfortunately I cannot use a PHP Excel-file-making library since the database is pretty large. All my exports must be done through MySQL.
If anybody knows how to make MySQL jump through Excel's hoops on this one, that would be great.
Many thanks,
Jack
Edit: This answer describes a solution that works for Excel 2007. Adding a 'BOM' to the file, which I may be able to do by providing the outputted file to the client via a PHP script that appends the BOM. Ideally I would like to find a solution that works in 2003 also.