Highlighted
Respected Contributor.
Respected Contributor.
2110 views

Re: Writing data in data table on each row

Jump to solution

Hi

I am script however it takes more than 30 minutes to complete which will be error-prone for object recognisation in IE, chrome etc.

In order to break down to several script, I need to write the parameter to data table e.g. first script is to create account, then I would like to write the account number created on the data table. 

Then next script will use the account no. from same datatable to do enquiry and other transaction.

Is there a way how script can writ data to data table?

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Honored Contributor.
Honored Contributor.

Hi there.

If this is only 1 parameter to be saved, have it saved to an ENVIRONMENT variable.
Check it out ->   File, Settings, Environment, user_defined. This will be valid in all your solution.

Next you can use Excel.Application objects.
Public Function  Save_to_Datatable(byval sTable, byval iRow,   val_to_save)

    Dim arrCols,oApp,i

    Set oApp = CreateObject("Excel.Application")
    oApp.WorkBooks.Open sTable

    'put value in table
     oApp.Cells(iRow+1, i+1).value = val_to_save
    oApp.ActiveWorkBook.Save
    oApp.quit
    Set oApp = Nothing

End
 Function

OR...

You can use the 
Datatable.export   OR  Datatable.ExportSheet
to save values to your runtime Excel sheet.

Check these out...

Have fun!

 

View solution in original post

0 Likes
3 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Hi there.

If this is only 1 parameter to be saved, have it saved to an ENVIRONMENT variable.
Check it out ->   File, Settings, Environment, user_defined. This will be valid in all your solution.

Next you can use Excel.Application objects.
Public Function  Save_to_Datatable(byval sTable, byval iRow,   val_to_save)

    Dim arrCols,oApp,i

    Set oApp = CreateObject("Excel.Application")
    oApp.WorkBooks.Open sTable

    'put value in table
     oApp.Cells(iRow+1, i+1).value = val_to_save
    oApp.ActiveWorkBook.Save
    oApp.quit
    Set oApp = Nothing

End
 Function

OR...

You can use the 
Datatable.export   OR  Datatable.ExportSheet
to save values to your runtime Excel sheet.

Check these out...

Have fun!

 

View solution in original post

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

hi

Thank you the suggestion.

I tried in this way:

DataTable.GetCurrentRow
DataTable.Value("gVisit","Global") = gVisit

DataTable.Export("C:\Input.xls")

where it is the data table i used.

I expect to get the gVisit on row 5 however it always goes to row 1.

I did try datatable.setcurrentRow(i) but no use.

Please kindly advise.

 

 

 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

This may be overlooked but...

Make sure you are using the  'setcurrentrow'  method BEFORE the set value command and before the save process.

Something like this:

iRow = iRow + 1
DataTable.GetSheet(cstr(sSheet)).SetCurrentRow(iRow)
DataTable.Value("STATUS", sSheet) = "N"
DataTable.Value("TIME_STAMP", sSheet) = Now()

DataTable.ExportSheet sFile , sSheet

 

Give this a go...

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.