Author Topic: Reading Listscreen data into Excel  (Read 7773 times)

Vivek Indripala

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 8
    • View Profile
Reading Listscreen data into Excel
« on: March 06, 2019, 03:26:03 AM »
Purpose:
Read List-screen data to excel.


Pre-Requisites:
1.Load wscurl library  load('wsoffice.dll');

In Below example data from column "Document" of listscreen is read into an Excel file by using position in set command.


Liquid UI Code :

/////////////////////////////////// RVKRED01.E0120.sjs ////////////////////////////////

load('wsoffice.dll');
pushbutton( [TOOLBAR], "scroll  ",{ "process": z_readfromlist });

function z_readfromlist(){    

       z_doc  = [];
       z_doc1 = [];
       z_doc2 = [];   
       lfvrow = 1;

      onscreen 'RVKRED01.0120'
              SCROLL_NEXT:;
              enter("/scrolltoline=&V[lfvrow]");
     
      onscreen 'RVKRED01.0120'
              enter("/hscrollto=0");


     if(lfvrow >= _listlastvisiblerow){
              goto END;
    }
   
    START:;
    lfvrow = _listfirstvisiblerow;
    llvrow = _listlastvisiblerow;
    z_row = 3;


    LOOP:;   
    set("V[doc_val]","&#["+z_row+",30]");
    set("V[doc_val1]","&#["+z_row+",72]");
    set("V[doc_val2]","&#["+z_row+",97]");   
    z_doc.push(doc_val);
    z_doc1.push(doc_val1);
    z_doc2.push(doc_val2);
    lfvrow = lfvrow+1;                 
    if(lfvrow <= _listlastvisiblerow){    
             z_row = z_row+1;
             goto LOOP;
    }
    else{
         goto SCROLL_NEXT
    }   
    END:;


   for(k=0;k<z_doc.length;k++){
         
      println("*******************************************************");
      println("document number at z_doc["+k+"]="+z_doc[k]);
      println("document Name at z_doc["+k+"]="+z_doc1[k]);
      println("document City at z_doc["+k+"]="+z_doc2[k]);
      println("*******************************************************");
   
   }   
    copy_To_Excel(zdoc,zdoc1,zdoc2)
}




function copy_To_Excel(zdoc,zdoc1,zdoc2)
{
   
   var ExcelApp = new ActiveXObject("Excel.Application");
   var ExcelSheet = new ActiveXObject("Excel.Sheet");   
   ExcelSheet.ActiveSheet.Cells(1,1).Value = "Doccument Number";
   ExcelSheet.ActiveSheet.Cells(1,2).Value = "Name of the Person";
   ExcelSheet.ActiveSheet.Cells(1,3).Value = "City";         
   for(p=2;p<z_doc.length;p++) {      
      ExcelSheet.ActiveSheet.Cells(p,1).Value = z_doc[p];
      ExcelSheet.ActiveSheet.Cells(p,2).Value = z_doc1[p];
      ExcelSheet.ActiveSheet.Cells(p,3).Value = z_doc2[p];      
   }   
   var str = "C:\\LiquidUI\\scripts\\TEST.XLS";      
   var fso = new ActiveXObject("Scripting.FileSystemObject");   
   if(fso.FileExists(str)){     
      message("E:FILE ALREADY EXISTS PLEASE REMOVE OLD FILE");
   }
   else{     
      ExcelSheet.SaveAs(str);   
      ExcelSheet.Application.Quit();
   
   }         
}      



see the attachments for further reference.