%% Create Import Options for Microsoft Word Document File
% Create import options for a Microsoft Word document file, specify the table to import, and then read the data.
% The file MaintenanceReport.docx contains two tables. The last row of the second table contains a cell with merged columns that do not match the table variables.
% Create a WordDocumentImportOptions object:
% Read five variables from the table.
% Read from the first table containing the word "Description" using the XPath query "//w:tbl[contains(.,'Description')]".
% Read variable names from the first row.
% Skip reading rows that have cells with merged columns.

opts = wordDocumentImportOptions( ...
    'NumVariables',5, ...
    'TableSelector',"//w:tbl[contains(.,'Description')]", ...
    'VariableNamesRow',1, ...
    'MergedCellColumnRule','omitrow')

% Read the table from the Microsoft Word document file using the readtable function with the options object.

filename = "MaintenanceReport.docx";
T = readtable(filename,opts)

% Copyright 2021 The MathWorks, Inc.