1 Reply Latest reply on Oct 25, 2011 3:27 PM by Jason Szeto

    how to solve ype Error: Error #2007: Parameter value must be non-null in flex4 mxml web application

    Venkatesan Balasubramanian Level 1

      Hello all,

       

      I am doing flex4 mxml web application,i am trying to export data from datagrid to excel,but when i running my code i got this following error:

       

      TypeError: Error #2007: Parameter value must be non-null.

          at flash.utils::ByteArray/writeUTFBytes()

          at com.as3xls.xls::ExcelFile/saveToByteArray()[/Users/manuelwudka-robles/Documents/Flex Builder 3/as3xls/com/as3xls/xls/ExcelFile.as:257]

          at com.ci.view::Reports/exportToExcel()[C:\Documents and Settings\TIVL\Adobe Flash Builder 4\CommissionManager1410\src\com\ci\view\Reports.mxml:680]

          at com.ci.view::Reports/___Reports_Button2_click()[C:\Documents and Settings\TIVL\Adobe Flash Builder 4\CommissionManager1410\src\com\ci\view\Reports.mxml:717]

       

       

      this is my code:

       

         private function exportToExcel():void

                          {

                                  sheet = new Sheet();

                                  var dataProviderCollection:ArrayCollection =

                       Reportgrid.dataProvider as ArrayCollection;

                                  var rowCount:int = dataProviderCollection.length;

                                  sheet.resize(rowCount+9,10);

                                  sheet.setCell(0,1,"name);

                                                  sheet.setCell(0,2,"address");

                                                  sheet.setCell(0,3,"phone");

                                                  sheet.setCell(0,4,"email");

                                                  sheet.setCell(0,5,"Fax";

                                                  sheet.setCell(0,6,"City");

                                                  sheet.setCell(0,7,"state");

                                                  sheet.setCell(0,8,"Country");

                                                  sheet.setCell(0,9,"Pincode");

                                  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+2,sheet,record);

                              }

                                  var xls:ExcelFile = new ExcelFile ();

                                                  xls.sheets.addItem (sheet);

                                                 

                                                  var bytes:ByteArray = xls.saveToByteArray();----->when this line comes the above error showing,

                                                  var fr:FileReference = new FileReference();

                                                  fr.save(bytes, "SampleExport.xls");

                   }

       

       

      How to solve this.

       

      Looking for useful suggession or sample snippet.

       

      Thanks in advance,

       

       

      Cheers,

       

      B.venkatesan.