I worked on a small project that required to export data to Excel. The spreadsheets needed to be formatted very precisely, and the best way to do this is with the XML format of an excel file. But I have found some gotchas throughout the project, which will cause the .xls files to not load.
First, since it is XML, you need to make sure you handle some special XML characters..
quotes “ should be "
ampersands & should be &
apostrophes ‘ should be '
less than < should be <
greater than > should be >
Now, if you make a function or something in code to do these operations, there is one thing to make sure of. Replace the & first. If you do it last, like the quick and dirty function I wrote first, then you could end up replacing a less than with < and then replacing that new ampersand with & so you end up with &lt; – whoops …
Another few little gotchas.. Excel tab names have to be distinct. If you have duplicates, the spreadsheet will still create just fine, you just wont be able to open it. Another thing with the tabs, you can have a division sign in them – / – same thing will happen.