{ 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(); } }
{ 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*/ trace("record = ",record); if (record == ""){ record = " "; // or set record = null; to see if something works } 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(); } }
trace("record = ",record); if (record == null ) { record = " "; }
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*/ trace("record = ",record); if (record == ""){ record = " "; // or set record = null; to see if something works } 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(); } }