How to verify or edit content in Excel sheets
This article contains a basic example of how data in Excel sheets can be verified or edited.
You would like to verify some data in your Excel sheet or modify the Excel sheet. This article will walk you through all the steps necessary to create an Excel file in a specified location, add some data, save it and then verify the data in it.
1) Import the standard Excel Modules
2) Make sure Microsoft® Excel 2003 or Microsoft® Excel 2007 is installed on your machine
3) Make sure the path "C:\Temp\" exists on your machine - create the "Temp" folder if it doesn't exist yet
1) To create the Excel sheet, the Module "Excel Open Workbook" is used:
The Workbook ID you specify in this TestStep allows Tosca to differentiate between different Excel sheets if multiple ones are opened during the execution. This ID can be chosen arbitrarily.
If you run this TestStep, a new Excel file called "Example.xlsx" will be created. Please note that this TestStep will load the Excel file programmatically, but no Excel GUI instance will be visibly opened.
2) Now that the Excel file is loaded, the next step is to insert some data. This can be done using "Excel Range Manipulation":
The usual classic table steering is used to manipulate the Excel sheet.
If multiple workbooks are open, Tosca will modify the one that was last opened or the one that was last set as the active workbook using "Excel Set Active Workbook".
3) We would now like to verify the value we just inserted:
4) In order for th changes we just made to take effect, the Excel file must be saved. "Excel Close Workbook" is used:
Notice how the workbook ID specified in step 1) is used to tell Tosca which workbook to close.
If you execute the complete TestCase with those 4 TestSteps, a new Excel file will be created in "C:\Temp\" with the text "This is row 2, column 1." in it.