Main Content

importFromDocument

Class: slreq.ReqSet
Package: slreq

Import editable requirements from external documents

Syntax

importFromDocument(rs, pathToFile, Name,Value)

Description

importFromDocument(rs, pathToFile, Name,Value) imports editable requirements with contents duplicated from an external document at pathToFile using by additional Name,Value arguments to specify import options.

Input Arguments

expand all

Requirement set file, specified as a slreq.ReqSet object.

Path to the requirements document that you want to import editable requirements from.

Example: 'C:\MATLAB\System_Requirements.docx'

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'ReqSet','design_specs.slreqx'

Option to import requirements as references, specified as a Boolean value. The value false is supported only for import from Microsoft® Office documents.

Import from ReqIF format, specifying the attribute mapping as a comma-separated pair consisting of 'attr2reqprop' and a containers.Map object. For example:

attrMap = containers.Map('KeyType','char','ValueType','char')
attrMap('SourceID') = 'Custom ID'; % Built-in attribute
attrMap('ReqIF.ChapterName') = 'Summary'; % Built-in attribute
attrMap('Data Class') = 'MyDataClass'; % Custom attribute

slreq.import('myfile.reqif','attr2reqprop',attrMap);

Example: slreq.import('myfile.reqif','attr2reqprop',attrMap);

Column in the Microsoft Excel® spreadsheet that you want to map as custom attributes of the requirements in your requirement set, specified as a double array.

Example: 'attributeColumn',[4 6]

Attribute names for custom attribute columns, specified as a cell array of character vectors.

Note

When importing requirements from a Microsoft Excel spreadsheet, the length of this cell array must match the number of columns specified for import using the attributeColumn argument.

Example: 'attributes',{'Test Status','Test Procedure'}

Option to import requirements content using user-defined bookmarks, specified as a 1 or 0 of data type logical.

By default, Requirements Toolbox™ sets the value to 1 for Microsoft Word documents and 0 for Microsoft Excel spreadsheets.

Example: 'bookmarks',false

Range of columns to import from Microsoft Excel spreadsheet, specified as a double array.

Example: 'columns',[1 6]

Column in the Microsoft Excel spreadsheet that you want to map to the CreatedBy property of the requirements in your requirement set, specified as a double.

Example: 'createdByColumn',5

Column in the Microsoft Excel spreadsheet that you want to map to the Description property of the requirements in your requirement set, specified as a double.

Example: 'descriptionColumn',2

Column in the Microsoft Excel spreadsheet that you want to map to the ID property of the requirements in your requirement set, specified as a double.

Example: 'idColumn',1

Name of the attribute from the external document that you want to map to the Keywords property for the imported requirements.

Use this argument when you import from IBM® Rational® DOORS® or custom document types.

Example: "keywords","Requirement Keywords"

Column in the Microsoft Excel spreadsheet that you want to map to the Keywords property of the requirements in your requirement set, specified as a double.

Example: 'keywordsColumn',3

Regular expression pattern for ID search in Microsoft Office documents.

Example: 'match','^REQ\d+'

Column in the Microsoft Excel spreadsheet that you want to map to the ModifiedBy property of the requirements in your requirement set, specified as a double.

Example: 'modifiedByColumn',6

Custom post-import callback script name to use during import, specified as a string scalar or character vector.

The script that you assign to this callback executes after you import or update requirements.

Example: "postImportFcn","myPostImportScript"

Custom pre-import callback script name to use during import, specified as a string scalar or character vector.

The script that you assign to this callback executes before you import or update requirements.

Example: "preImportFcn","myPreImportScript"

Name of the attribute from the external document that you want to map to the Rationale property for the imported requirements.

Use this argument when you import from IBM Rational DOORS or custom document types.

Example: "rationale","Requirement Rationale"

Column in the Microsoft Excel spreadsheet that you want to map to the Rationale property of the requirements in your requirement set, specified as a double.

Example: 'rationaleColumn',5

The name for the requirement set that you import requirements into, specified as a character vector.

If the requirement set exists, the requirements import under a new Import node. If the requirement set does not exist, Requirements Toolbox creates it.

Example: 'ReqSet','My_Requirements_Set'

Option to import requirements as rich text, specified as a Boolean value.

Example: 'RichText',true

Range of rows to import from Microsoft Excel spreadsheet, specified as a double array.

Example: 'rows',[3 35]

Worksheet name from Microsoft Excel workbook, specified as a character vector.

Example: 'sheet','Sheet1'

Column in the Microsoft Excel spreadsheet that you want to map to the Summary property of the requirements in your requirement set, specified as a double.

Example: 'summaryColumn',4

Import from Microsoft Excel spreadsheets specified in the USDM (Universal Specification Describing Manner) standard format. Specify values as a character vector with the ID prefix optionally followed by a separator character.

Example: 'RQ -' will match entries with IDs similar to RQ01, RQ01-2, RQ01-2-1 etc.

Examples

Import Editable Requirements from Microsoft Office Documents

% Create a new requirement set and save it
rs = slreq.new('newReqSet');
save(rs);

% Import editable requirements as rich text from a Word document
importFromDocument(rs, 'C:\Work\Requirements_Spec.docx', ...
 'RichText', true);

% Import editable requirements from an Excel spreadsheet
importFromDocument(rs, 'C:\Work\Design_Spec.xlsx', ... 
'columns', [2 6], 'rows', [3 32], 'idColumn', 2, ...
'summaryColumn', 3);
For more information on importing requirements from Microsoft Office documents, see Import Requirements from Microsoft Office Documents.

Version History

Introduced in R2018a