- 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.
- Moodle Administration Essentials
- 自制編譯器
- C語言程序設計基礎與實驗指導
- Production Ready OpenStack:Recipes for Successful Environments
- Hadoop+Spark大數據分析實戰
- 你必須知道的204個Visual C++開發問題
- Mastering Ext JS
- Learning Apache Mahout Classification
- Unreal Engine 4 Shaders and Effects Cookbook
- IDA Pro權威指南(第2版)
- 石墨烯改性塑料
- Angular Design Patterns
- DB2SQL性能調優秘笈
- Hands-On ROS for Robotics Programming
- Raspberry Pi Robotic Projects