addExcelSpecification

Package: sltest.testmanager

Add a Microsoft Excel sheet to baseline criteria or test case inputs

Syntax

addExcelSpecification(obj,'Sheet',sheet)
addExcelSpecification(obj,'Sheet',sheet,'Range',range)

Description

example

addExcelSpecification(obj,'Sheet',sheet) adds the specified Excel® sheet to the baseline criteria or test case inputs obj.

addExcelSpecification(obj,'Sheet',sheet,'Range',range) adds the cells in the specified range to the baseline criteria or test case inputs.

Examples

collapse all

Create the test file, test suite, and test case structure.

tf = sltest.testmanager.TestFile('Add Excel Test');
ts = createTestSuite(tf,'Add Excel Suite');
tc = createTestCase(ts,'baseline','Baseline Excel Test Case');

Add baseline criteria from an Excel file. Specifying two sheets creates two baseline criteria.

base = addBaselineCriteria(tc,'C:\MATLAB\baseline.xlsx','Sheets',{'Optics','Converter'});

Add the sheet X2Out to the first set.

base(1).addExcelSpecification('Sheet','X2Out');

Show the contents of the Sheet property of the Excel specifications for each baseline criteria. The first set now includes the X2Out sheet.

base(1).ExcelSpecifications(:).Sheet
ans =

    'Optics'


ans =

    'X2Out'
base(2).ExcelSpecifications(:).Sheet
ans =

    'Converter'

Input Arguments

collapse all

Excel sheet to add to baseline criteria or test case inputs, specified as a character vector.

Example: 'Optics'

Range of cells from the specified sheet to add to test case inputs, specified as a character vector or string in one of these forms:

Ways to specify Range Description

'Corner1:Corner2'

Rectangular Range

Specify the range using the syntax 'Corner1:Corner2', where Corner1 and Corner2 are two opposing corners that define the region. For example, 'D2:H4' represents the 3-by-5 rectangular region between the two corners D2 and H4 on the worksheet. The 'Range' name-value pair argument is not case-sensitive, and uses Excel A1 reference style (see Excel help).

Example: 'Range','Corner1:Corner2'

''

Unspecified or Empty

If unspecified, the importing function automatically detects the used range.

Example: 'Range',''

Note: Used Range refers to the rectangular portion of the spreadsheet that actually contains data. The importing function automatically detects the used range by trimming leading and trailing rows and columns that do not contain data. Text that is only white space is considered data and is captured within the used range.

'Row1:Row2'

Row Range

You can identify the range by specifying the beginning and ending rows using Excel row designators. Then readtable automatically detects the used column range within the designated rows. For instance, the importing function interprets the range specification '1:7' as an instruction to read columns in the used range in rows 1 through 7 (inclusive).

Example: 'Range','1:7'

'Column1:Column2'

Column Range

You can identify the range by specifying the beginning and ending columns using Excel column designators. Then readtable automatically detects the used row range within the designated columns. For instance, the importing function interprets the range specification 'A:F' as an instruction to read rows in the used range in columns A through F (inclusive).

Example: 'Range','A:F'

'NamedRange'

Excel’s Named Range

In Excel, you can create names to identify ranges in the spreadsheet. For instance, you can select a rectangular portion of the spreadsheet and call it 'myTable'. If such named ranges exist in a spreadsheet, then the importing function can read that range using its name.

Example: 'Range','myTable'

Example: 'A1:C20'

Introduced in R2017b