0 Replies Latest reply on Oct 20, 2011 4:22 AM by Venkatesan Balasubramanian

    how to export data from datagrid to excel sheet in flex 4 mxml web application.

    Venkatesan Balasubramanian Level 1

      Hello friends,

       

       

      I am having one data grid it having 9 columns and 10 rows, now i want to export this data into to excel,how to creat new excel and export this data into a excel

       

      to that excel,

       

      i didnt that i saved all values in byte,i dont know how to save the bytes in flex4.

      then also when i open the excel all values spread in to the excel how to make perfect.i have some problem in that please help,

       

      this is my code:

       

      var sheet:Sheet=new Sheet();

                      sheet.resize(100,100);

                      var ReportdetailsDTOlength : uint=model.CommRecordsList.length;

                      var r:int;

                      for(r=0;r<ReportdetailsDTOlength;r++){

      sheet.setCell(r+1,0,"AdviceNo:");
      sheet.setCell(r+2,1,"Name:");
      sheet.setCell(r+3,2,"age:");
      sheet.setCell(r+4,3,"address");
      sheet.setCell(r+5,4,"city:");
      sheet.setCell(r+6,5,"telephone);
      sheet.setCell(r+7,6,"fax:");
      sheet.setCell(r+8,7,"mail id");
      sheet.setCell(r+9,8,"date of birth");

       

      var xls:ExcelFile=new ExcelFile();

                      xls.sheets.addItem(sheet);

                      var bytes:ByteArray=xls.saveToByteArray();

                      var fr1:FileReference=new FileReference();

                      fr1.save(bytes,"");

       

      i got excel but i didnt get the details are not clear,

       

      name, age, address,city,telephone,fax,mail id and date of birth are datafield of data grid.

      How to do that please help me.

      Please give any useful suggession or snippet sample.

       

       

      Thanks in advance,

       

      cheers,

      B.venkatesan