UTF-8 encoding is not supported by the current implementation of as3xls. The saveToByteArray
function uses a BIFF2 (Excel 2.x) stream for encoding which doesn't support UTF-8.
All Excel file formats up to BIFF5 contain simple byte strings. The
byte string consists of the length of the string followed by the
character array. ... The encoding of the character array is dependent
on the current record, for example taken from the CODEPAGE record.
A quick-fix could be to change the saveToByteArray()
function in ExcelFile.as
to
public function saveToByteArray(codePageID: int, charSet: String):ByteArray
Add these lines after br.writeTag(bof);
if (codePageID > 0)
{
var codePage:Record = new Record(Type.CODEPAGE);
codePage.data.writeShort(codePageID);
br.writeTag(codePage);
}
and change cell.data.writeUTFBytes(value);
to cell.data.writeMultiByte(value, charSet);
This way you can adjust the character set to your needs.
var xls:ExcelFile = new ExcelFile();
...
// write xls with cyrillic characters
var bytes:ByteArray = xls.saveToByteArray(28595, "iso-8859-5");
Further reading: