Hi guys,I am using an excel library to create a tool that saves the datagrid to an excel file. However if the records are blank, the excel shows zeros, instead of blank records. How would I change the code so the blank records show up as blank? Thank youHere is the link to the libraryhttp://code.google.com/p/as3xls/and here is the code snippet
{
CursorManager.setBusyCursor();
sheet = new Sheet();
var dataProviderCollection:ArrayCollection = excelgrid.dataProvider as ArrayCollection;
var rowCount:int = dataProviderCollection.length;
sheet.resize(rowCount + 1,excelgrid.columnCount);
var columns:Array = excelgrid.columns;
columns.splice(0, 1) // to delete the first column which is the number of each record , because this field has no datafield, the excel
//function does not work if we include it in the table like it is included now
var i:int = 0;
for each (var field:DataGridColumn in columns)
{
fields.push(field.dataField.toString());
sheet.setCell(0,i,field.dataField.toString());
i++;
}
for(var r:int=0; r < rowCount; r++)
{
var record:Object = dataProviderCollection.getItemAt(r);
/*insert record starting from row no 2 else
headers will be overwritten*/
insertRecordInSheet(r+1,sheet,record);
}
var xls:ExcelFile = new ExcelFile();
xls.sheets.addItem(sheet);
CursorManager.removeBusyCursor();
var bytes: ByteArray = xls.saveToByteArray();
var fr:FileReference = new FileReference();
fr.save(bytes,"DirectoryofForestProductsIndustries.xls");
}
else
{
Alert.show("Make sure your search produces any results before using this tool");
CursorManager.removeBusyCursor();
}
}