I want to upload excel file and show the content of uploaded excel file data grid. Everything is going well. But when i convert the the content in the form of byteArray in excel sheet format with the help of loadFromByteArray() function then system is giving me error as "Cannot access a property or method of a null object reference".
Here is my code to upload excel content:
protected function browseExcelFile(event:MouseEvent):void
{
excFileRef = new FileReference();
excFileRef.addEventListener(Event.SELECT, onSelect);
excFileRef.addEventListener(Event.COMPLETE, onComplete);
var fileFilter:FileFilter = new FileFilter("Excel (.xls)", "*.xls");
excFileRef.browse([fileFilter]);
}
private function onSelect(event:Event):void {
excelFileName.text = excFileRef.name;
excFileRef.load();
}
private function onComplete(event:Event):void {
excelFileName.text = excFileRef.name;
exceldataInByte = new ByteArray();
exceldataInByte = event.currentTarget.data;
if(exceldataInByte.length > 0){
var excObj:ExcelFile = new ExcelFile();
excObj.loadFromByteArray(exceldataInByte); /* this line give error */
var sheet:Sheet = excObj.sheets[0];
}
}
I dont know why this error occuring, i have searched on many sites but everywhere everyone posted the same way as i have done to upload excel but my code gives me error.
Please tell me why this error occur?