Exporting sheets from Excel documents

Last edited on

Squish 6.5.x and newer

Squish supports reading all of the data from an excel document. You can now read from individual sheets through the use of

testData.datasetExcel

this function returns a dataset object based on the sheet name given as the second argument. The default is the first sheet of the given excel file.

Squish 6.4 and earlier

The testData API of Squish only supports reading the first sheet from Excel documents.

However, the following external tool ( export_xls_sheet , based on Python 2.6 (or higher) and the xlrd and xlwt modules) can be used to export every desired sheet into a separate Excel document, so that it can then be read via the testData API.

path/to/python path/to/export_xls_sheet.py input_file sheet_index output_file
General usage of export_xls_sheet

The sheet_index for the first sheet is 0.

Using <code>export_xls_sheet</code> with JavaScript test scripts

function main()
{
    OS.system('"path/to/python.exe" "path/to/export_xls_sheet.py" "read_from_this.xls" 0 "write_to_this.xls"');
}
test.js

Using <code>export_xls_sheet</code> with Python test scripts

import os

def main():
    os.system('"path/to/python.exe" "path/to/export_xls_sheet.py" "read_from_this.xls" 0 "write_to_this.xls"')
test.py