AS -> View
*/
private function convert(data:ByteArray):void
{
try
{
// Load the embedded spreadsheet and get the first sheet
var excelFile:ExcelFile = new ExcelFile();
excelFile.loadFromByteArray(data);
var sheet:Sheet = excelFile.sheets[0];
// Display the sheet in the grid
grid.dataProvider = sheet.values;
}
catch(error:Error)
{
Alert.show("Fail to convert excel")
}
}
/**
* save Excel to local file (for Astro)
*/
private function saveCSV():void
{
//var arr:ArrayCollection = ArrayCollection(grid.dataProvider);
var arr:Array = (grid.dataProvider.source as Array);
var str:String = "";
for (var i:int = 0; i < arr.length; i++)
{
str += arr[i].toString()
str += "\r\n"
}
fl = new FileReference();
fl.save(str, "astro_"+(new Date().getTime())+".csv");
}
]]>