I want to get data from xls file with help of as3xls.
private var file:FileReference = new FileReference();
private var sheet:Sheet;
private var loadedFile:ByteArray;
private function sendLogistImport():void {
file.addEventListener(Event.SELECT, onFileSelect);
file.browse();
file.addEventListener(Event.COMPLETE,
function (e:Event):void {
loadedFile = e.currentTarget.data as ByteArray;
var excelFile:ExcelFile = new ExcelFile();
excelFile.loadFromByteArray(loadedFile);
sheet = excelFile.sheets[0];
Alert.show(sheet.getCell(1,0).value);
}
);
}
private function onFileSelect(e:Event):void {
file.load();
}
But I get this error at the excelFile.loadFromByteArray(loadedFile);:
Error: Error #2030: End of file was encountered.
at flash.utils::ByteArray/readUTFBytes()
at com.as3xls.xls::ExcelFile/boundsheet()[/Users/manuelwudka-robles/Documents/Flex Builder 3/as3xls/com/as3xls/xls/ExcelFile.as:633]
at Function/http://adobe.com/AS3/2006/builtin::call()
at com.as3xls.xls::ExcelFile/loadFromByteArray()[/Users/manuelwudka-robles/Documents/Flex Builder 3/as3xls/com/as3xls/xls/ExcelFile.as:309]
at Function/<anonymous>()[D:\logist.as:244]
This is my xls file's screenshot :
Here is my xls file: http://www.filedropper.com/template_1
Please tell me, where is my mistake?
I've tested it with various XLS formats, and it can't read any of them. Judging from the comments, the support for the various XLS formats is rather bad.
Try it with different XLS formats, maybe you find one that works, other than that I'm afraid I can't help you, fixing the problem in the library is a monstrous task, and I wouldn't touch it with a ten-foot pole: http://www.openoffice.org/sc/excelfileformat.pdf
Also check out some of the forks around the net, like for example https://github.com/djw/as3xls, they may have some fixes implemented that get you going.
And if nothing work for you, then I'd suggest to look for another library, and/or even use a totally different file format (like CSV) if that is an option.