3 Replies Latest reply on May 18, 2010 7:14 AM by TanweerHq

    Export to Excel

    Arunkumar S

      Hi All,

       

           Is there anyway available in flex to export the data into Excel?

           I'm using Advanceddatagrid. When the user presses the Export button, the data available in the Advanceddatagrid has to be exported to an Excel. Thanks in advance for the help.

        • 1. Re: Export to Excel
          BhaskerChari Level 4

          Hi,

           

          Try to refer the below link...there is one sample included.

           

          http://frankfenghua.blogspot.com/2007/07/flex-export-datagrid-to-excel.html

           

           

          Thanks ,

          Bhasker Chari

          • 2. Re: Export to Excel
            Arunkumar S Level 1

            Thanks for the link Bhasker. It would be more helpful if there is a link for working example.

            • 3. Re: Export to Excel
              TanweerHq Level 2

              All you need to do is - create a HTMl script and save it as .xls

               

               

              {

              ...

              ...

               

              say 'strHTMLText' is having html tags, pass this 'strHTMlText' here below:


              var applicationDirectoryPath:File             = File.documentsDirectory.resolvePath("MyExcelFile.xls") 
              var nativePathToApplicationDirectory:String = applicationDirectoryPath.nativePath.toString();
                             
                             
                              fileName = nativePathToApplicationDirectory ;
                             
                              var file:File     = new File(nativePathToApplicationDirectory);

               

                                  var stream:FileStream = new FileStream();

               

                                  stream.open(file, FileMode.WRITE);

               

                                  stream.writeUTFBytes(strHTMLText);

                                  stream.close();

               

                              callLater(openExcel);

              }

               

              private function openExcel():void            
                           {
                               navigateToURL(new URLRequest(fileName),"_blank");
                           }

              1 person found this helpful