ExportSheet Method

Description

Exports a specified sheet of the design-time or run-time data table to the specified sheet in the specified file.

  • If you do not specify a destination sheet name, the source sheet name is used for the destination.
  • If the specified file does not exist, a new file is created and the specified sheet is saved.
  • If the current file exists, but the file does not contain a sheet with the specified sheet name, the sheet is inserted as the last sheet of the file.
  • If the current file exists and the file contains the specified sheet, the exported sheet overwrites the existing sheet.

For details on exporting data sheets from components and Business Process Tests, see the topic on importing and exporting data sheets in the UFT One Help Center.

Syntax

DataTable.ExportSheet FileName, vtSrcSheet, [DstSheetName]

Argument

Type

Description

FileName
String
The full file system path of the Excel table to which you want to export a sheet.
vtSrcSheet
Variant
The name or index of the design-time or run-time Data pane sheet that you want to export. Index values begin with 1.
DstSheetName
Variant
Optional. The name of the sheet in the file that you want to create or replace with the data from vtSrcSheet.

Example

The following example uses the ExportSheet method to save the first sheet of the design-time or run-time data table to the name.xls file.

DataTable.ExportSheet "C:\name.xls" ,1

The following example creates separate output data table sheets for each iteration of the test.
The test retrieves the number of the row being handled in the current iteration, modifies a value in the global data sheet and then exports the global sheet to a new sheet, named according to the row number.

currentRow = DataTable.GetCurrentRow
DataTable("Param1", dtGlobalSheet) = currentRow
exportedSheetName = "Global-" & currentRow
DataTable.ExportSheet "c:\result.xls", "Global", exportedSheetName