Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeros instead of blanks? #60

Open
GoogleCodeExporter opened this issue Jun 30, 2015 · 0 comments
Open

Zeros instead of blanks? #60

GoogleCodeExporter opened this issue Jun 30, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link


Can anybody tell me why the records with blanks on the datagrid show as zeros 
instead of blanks? Thanks

    {

                    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();
                }

            }





            private function insertRecordInSheet(row:int,sheet:Sheet,record:Object):void
            {
                var colCount:int = excelgrid.columnCount;
                for(var c:int; c < colCount; c++)
                {
                    var i:int = 0;
                    for each(var field:String in fields)
                    {
                        for each (var value:String in record)
                        {
                            if (record[field].toString() == value)
                                sheet.setCell(row,i,value);
                        }
                        i++;
                    }


                }


            }

Original issue reported on code.google.com by [email protected] on 3 Dec 2012 at 3:52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant