Excel File Interaction
You can use SenseTalk to access data stored in Microsoft Excel format. Using the functions in this section, SenseTalk reads and writes data directly in individual cell values.
You can update and write values back to an Excel spreadsheet file, and update properties, such as text color or font size, in a cell. For example, you could configure SenseTalk to read data from a spreadsheet, use this data to drive tests, then write the test results back to the spreadsheet.
Interactions with Excel databases occur through several special types of objects which serve as references to different elements within an Excel file. A workbook object refers to the workbook as a whole, and serves as the starting point for all access to the workbook file. A worksheet object is a reference to a single worksheet within a workbook. A cell object is a reference to a single cell within a worksheet.
Because these objects act as references to the respective parts of an Excel workbook file, changing any property of one of these objects or the value of a cell will change the corresponding aspect of the workbook itself. When passing one of these objects as a parameter to a command or function, you must explicitly pass it by reference if you want to access the workbook from the called handler. Otherwise SenseTalk will make a copy of the object and the value received by the called handler will no longer have a connection to the workbook.
The functions described here are distinct from SenseTalk’s database capabilities. To access the contents of a spreadsheet as a database, see Working with Excel as a Database.
File References
As a best practice, any files referenced within a SenseTalk script should be added to Eggplant Functional through the Resources pane in the Suite window. This method stores files to the Resources directory within the suite directory for the given suite. Although SenseTalk can access files stored elsewhere on the local file system, using the Resources directory provides additional capabilities. See the Resources Pane for more information.
Creating Multiple Connections to an Excel File
While Eggplant Functional allows you to create more than one connection to an Excel file, doing so can lead to issues and errors. For example, if you connect to an Excel file as both a workbook (described on this page) and as a database (described here), Eggplant Functional might return an error message like InternalWorkbookError - data source needed but no workbook value
. You can fix this error by closing one of the connections.
To directly read data from or write data to an Excel file, use these functions and properties:
The Workbook
Function identifies the workbook file and provides a starting point for accessing it using the other functions.
The Worksheet
Function identifies a specific worksheet within a workbook.
The Cell
Function gives access to the value and properties of a specific cell within a worksheet.
The CellRange
Function lets you quickly access multiple cells in a range of rows, columns, or rectangular region of a worksheet.