0 Replies Latest reply on Jul 29, 2011 10:13 AM by PankajVERCM

    Browse excel file and read the contest of selected file?




      I am new to flex and want to browse and excel file and read the content of the file and populate on the page.


      I am able to read the excel file  using following code which use  as3xls library




      import com.as3xls.xls.ExcelFile;


      import com.as3xls.xls.Sheet;




      private function init():void {



      var request:URLRequest = new URLRequest("c:\\test.xls");


      var urlLoader:URLLoader = new URLLoader(request);

      urlLoader.addEventListener(Event.COMPLETE, onURLLoaderComplete);

      // Once file loaded, function call onURLLoaderComplete

      urlLoader.dataFormat = URLLoaderDataFormat.BINARY;

      // to Read Data in Binary Format




      fileRef =

      new FileReference();

      fileRef.addEventListener(Event.SELECT, onURLLoaderComplete);


      //fileRef.addEventListener(ProgressEvent.PROGRESS, fileRef_progress);

      fileRef.addEventListener(Event.COMPLETE, onURLLoaderComplete);



      private function onURLLoaderComplete(event:Event):void


      valuesArrayNew =

      new ArrayCollection();

      loadedFile = event.target.data;


      var excelFile:ExcelFile = new ExcelFile();


      sheet = excelFile.sheets[0];

      // Reads sheet1



      // Imports all excel cells to Datagrid




      for(var i:int =0;i< (valuesArray.length-1);i++)


      valuesArrayNew.addItem({PORTFOLIO_NAME:valuesArray[i+1][0],ANALYSIS_DATE:valuesArray[i+1][ 1],CUSIP:valuesArray[i+1][2],COLLATERAL_TYPE:valuesArray[i+1][3],CURRENT_POSITION:valuesAr ray[i+1][4]});




      // getCell(Row, Col)






      Also, i am able to browse the file using

      FileReference.browse method but i am having difficuly in reading the selected browsed excel and display the data.


      It would be really nice if someone can help meresolve this issue.