xlsx2struct
datatypes: s = xlsx2struct (filename)
Read every sheet of an Excel workbook into a scalar structure.
s = xlsx2struct (filename) reads each sheet of the Office
Open XML workbook named by filename (.xlsx or .xlsm)
into a table and returns a scalar structure with one field per sheet,
in sheet order. Each sheet is read as by readtable (variable names
from the first row, types detected automatically); it is the inverse of
struct2xlsx.
A sheet name that is not a valid structure field name is canonicalised with
matlab.lang.makeValidName (and made unique if two names collide); when
the field name differs from the sheet name the original is stored on that
field’s table as the 'ActualSheetName' custom property, so a
subsequent struct2xlsx restores the exact sheet name.
See also: struct2xlsx, readtable, writetable, ods2struct
Source Code: xlsx2struct
xlsx2struct is the inverse of struct2xlsx: it reads every worksheet of an Excel workbook into a scalar struct, one field per sheet, in sheet order.
wb.Patients = table ({'Li'; 'Diaz'}, [38; 40], 'VariableNames', {'Name', 'Age'});
wb.Visits = table ([1; 2; 3], 'VariableNames', {'Visit'});
filename = fullfile (tempdir (), 'clinic.xlsx');
struct2xlsx (filename, wb);
s = xlsx2struct (filename);
s.Patients
ans =
2x2 table
Name Age
________ ___
{'Li' } 38
{'Diaz'} 40
delete (filename);