Exporting a DataTable

We may need to save data that is collected during a run session. For example, a comparison of the current result with previous results might be required. Alternatively, we might wish to update the expected results. In such scenarios, we can save the data to an external Excel sheet for later use.

How to do it...

To save the DataTable in its current state before the run session ends, we will use the DataTable.Export method, which takes the path and name of an Excel file as an argument. There are two options to save the data table:

  • Using a hardcoded filename:
    DataTable.Export(Environment("TestDir") & "\MyDynamicallySavedExcel.xls")
  • Using a variable filename:
    DataTable.Export(Environment("TestDir") & "\" & strFileName & ".xls")

How ...

Get Advanced UFT 12 for Test Engineers Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.