Sunday 8 July 2012

Export data to xlsx from Action1 datatable

  Set qSheet=DataTable.GetSheet("Action1")
fn=qSheet.getparametercount

Set ExcelApp=CreateObject("Excel.Application") 
ExcelApp.visible=true
     Set ExcelFile=ExcelApp.WorkBooks.Open ("E:\new.xls") 
     Set ExcelSheet = ExcelApp.WorkSheets("Sheet1") 
 
  rowcount= qSheet.getrowcount

For index1=1 to fn
fname=qSheet.getparameter(index1).name
ExcelSheet.cells(1,index1)=fname

next

For i=2 to  rowCount+1
For j=1 to fn
    fg=qSheet.getparameter(j).valuebyrow(i-1) 
ExcelSheet.cells(i,j)=fg
    next
Next

ExcelFile.save
ExcelFile.close
ExcelApp.quit