4 Reference - essenius/FitNesseFitSharpExcel GitHub Wiki

Script Table Excel – Workbook/Worksheet management

Close Workbook
Description: Close an open workbook
In: workbook name, or nothing for current workbook
Out: whether closing succeeded (true/false)
Example(s): | close workbook | TestSheet.xlsx |
| close workbook |
Close Excel
Description: Close the Excel application (without saving)
In: -
Out: -
Example(s): | close excel |
Load Workbook
Description: Load a workbook
In: workbook name
Out: whether loading succeeded (true/false)
Example(s): | load workbook | TestSheet.xlsx |
Load Workbook Read Only
Description: Load a workbook in read-only mode (bypassing the read/write password dialog)
In: workbook name
Out: whether loading succeeded (true/false)
Example(s): | load workbook | TestSheet.xlsx | read only |
Protect Workbook With Password
Description: Protect the current workbook
In: password
Out: whether protecting succeeded (true/false)
Example(s): | protect workbook with password | secret123 |
Protect Worksheet With Password
Description: Protect the current worksheet
In: password (can be empty)
Out: whether protecting succeeded (true/false)
Example(s): | protect worksheet with password | secret123 |
| protect worksheet with password | |
Note: The last example shows how to protect a sheet without a password (i.e. using two pipes, showing the password is empty)
Select Workbook
Description: Switch to an already open workbook
In: workbook name
Out: whether the operation succeeded (true/false)
Example(s): | Select workbook | TestSheet.xlsx |
Select Worksheet
Description: Switch to a worksheet of the current workbook
In: worksheet name or number (1 based)
Out: whether the operation succeeded (true/false)
Example(s): | Select worksheet | Sheet2 |
| Select worksheet | 1 |
Unprotect Workbook With Password
Description: Unprotect the current workbook
In: password
Out: whether unprotecting succeeded (true/false)
Example(s): | unprotect workbook with password | secret123 |
Unprotect Worksheet With Password
Description: Unprotect the current worksheet
In: password
Out: whether unprotecting succeeded (true/false)
Example(s): | unprotect worksheet with password | secret123 |
Note: If the worksheet is protected without a password, the password argument is ignored (so unprotection will succeed).
Workbook Is Protected
Description: Check if the current workbook is protected
In: -
Out: whether the workbook is protected (true/false)
Example(s): | workbook is protected |
Worksheet Is Protected
Description: Check if the current worksheet is protected (with or without password)
In: -
Out: whether the worksheet is protected with a password (true/false)
Example(s): | worksheet is protected |
Worksheet Is Protected With Password
Description: Check if the current worksheet is protected with a password
In: -
Out: whether the worksheet is protected with a password (true/false)
Example(s): | worksheet is protected with password |

Script Table Excel – Testing on Worksheet

Addresses can be in the format $A$1, A1 or a name

||Cell With Text Description:|Find a cell containing text. Search is case insensitive. In:|scope (Partial or Full), text to search Out:|address of the first cell with the sought text. Example(s):|\| $cell= \| Cell with \| full \| Text \| Costs Per Month \|
\| $cell= \| Cell with \| partial \| Text \| Month \| Note:|if the scope starts with Part then a partial match is done, other wise a full match.

Click Button
Description: Click a button
In: Name or caption of the button
Out: whether the operation succeeded (true/false)
Example(s): | Click button | Button 1 |
| Click Button | Calculate Cost Per Year |
Execute
Description: Execute a macro, function or expression
In: expression to evaluate
Out: formula of the cell
Example(s): | check | execute | 2^5 | 32 |
| check | Execute | Add(3,7) | 10 |
Note: Throws an EvaluateException if Excel returns an error (#DIV/0!, #N/A, #NAME?, #NUM!, #REF!, #VALUE!)
Formula Of Cell
Description: Get the formula of a certain cell
In: cell address
Out: formula of the cell
Example(s): | check | Formula of cell | square | =B13^2 |
Last Cell
Description: Get the address of the bottom right cell of the sheet
In: -
Out: The last cell on the worksheet (in $A$1 format)
Example(s): | $last= | last cell |
Offset By Rows And Columns
Description: Get the address of the range that is offset a number of columns and rows from the input range
In: cell range, rows, columns
Out: The offset range
Example(s): | check | offset | A1 | by | 3 | rows and | 4 | columns | $E$4 |
Set Value Of Cell To
Description: Set the value of a certain cell
In: cell address, value
Out: whether setting the value succeeded (true/false)
Example(s): | Set value of cell | $A$1 | to | 23 |
Text Of Cell
Description: Get the text in a certain cell
In: cell address
Out: value of the cell
Example(s): | check | Text of cell | $B$13 | 347.2222 |
Note: Different from Value Of Cell in that it returns the displayed text, not the actual value
Value Of Cell
Description: Get the value of a certain cell
In: cell address
Out: value of the cell
Example(s): | check | Value of cell | $B$13 | ~=347.22 |

Query Table: Excel Query

The query table fixture Excel Query allows you to extract a certain range on a worksheet, and compare these against an expected set of table values. It takes as parameter a reference to a script fixture where the correct worksheet was selected, a range to be extracted, and whether the first row is expected to contain headers (UseHeaders or something else). The page Query Based Excel Testing shows the details.

⚠️ **GitHub.com Fallback** ⚠️