- Advanced UFT 12 for Test Engineers Cookbook
- Meir Bar Tal Jonathon Lee Wright
- 243字
- 2021-08-05 17:09:12
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 it works...
The preceding statement saves the current contents of the DataTable (all worksheets) to a new Excel file (if not existent, otherwise it is overwritten). The statement Environment("TestDir")
returns a string with the path of the current test to which a string with the name of the file we wish to create is concatenated (TestDir
is one of the built-in Environment variables covered in detail later in this chapter).
There's more...
To export just a single worksheet (in our example, the global sheet) for an action, use the DataTable.ExportSheet
method, as follows:
call DataTable.ExportSheet(Environment("TestDir") & "\MyDynamicallySavedSheet1.xls", "Global")
Here, the first parameter is the Excel filename and the second is the source datasheet. The target datasheet will take the same name as the source.
- The Complete Rust Programming Reference Guide
- ExtGWT Rich Internet Application Cookbook
- Fundamentals of Linux
- Learning RabbitMQ
- Podman實戰
- PLC編程及應用實戰
- Lighttpd源碼分析
- Spring Security Essentials
- 軟件體系結構
- Unity Character Animation with Mecanim
- Web Developer's Reference Guide
- Practical Predictive Analytics
- 嵌入式C編程實戰
- 企業級Java現代化:寫給開發者的云原生簡明指南
- Office VBA開發經典:中級進階卷