views:

35

answers:

1

Hello,

I have a Flex application with a couple of DataGrids with data. I'd like to save the data to a file so that the user can keep working with them in Excel, OpenOffice or Numbers.

I'm currently writing a csv file straight off, which opens well in OpenOffice or Numbers, but not in Excel. The problem is with the Swedish characters ÅÄÖ, which turn up as other characters when opening in Excel. Converting (in Notepad++) the csv-file to ANSI encoding makes the ÅÄÖ show up correctly in Excel.

Is there any way to write ANSI-encoded files straight from Flex?

Any other options for writing a file that can be opened in Excel and OpenOffice?

(I've looked at the as3xls library, but according to the comments those files cannot be opened in OpenOffice)

+1  A: 

Using the writeMultiByte function from the ByteArray class allows you to specify a character set. See :

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/utils/ByteArray.html#writeMultiByte%28%29

PeZ
Thank you, that made it work in Excel and OpenOffice (where the encoding can be set). Now Numbers got mixed up, but that is an edge case that I can support later with a switch if necessary.
Lizzan