ods2table
datatypes: tbl = ods2table (filename)
datatypes: tbl = ods2table (filename, 'Sheet', sheet)
Read an OpenDocument spreadsheet file into a table.
tbl = ods2table (filename) reads the OpenDocument
spreadsheet named by filename, which may be a character vector, a
cellstr, or a string scalar, and returns it as a table. Both the
compressed .ods and the flat .fods formats are read; the
format is detected from the file contents, not its extension.
tbl = ods2table (…, reads a
specific sheet, selected either by its name (a character vector or string
scalar) or by a 1-based index over the data sheets. Without this option the
first data sheet is read.
'Sheet', sheet)
When the file carries the hidden __datatypes_meta__ sheet written by
the table2ods method, the variable types, names, descriptions, and
units are restored from it, and date and time cells are
reconstructed as datetime and duration arrays. Integers are
restored without loss of precision and missing cells become NaN,
NaT, or missing strings as appropriate.
When the metadata sheet is absent (a spreadsheet written by another
application) the variable types are inferred from the cell value types and
the variables are named Var1, Var2, and so on.
The following round-trip limitations apply, mirroring csv2table:
calendarDuration and categorical variables are returned as cell
arrays of character vectors (their values are not reconstructed), missing
string values are read back as empty strings, and datetime and
duration display formats are not preserved, although the values themselves
are exact.
Source Code: ods2table
ods2table reads an OpenDocument spreadsheet into a table. With no options it reads the first data sheet.
T = table ([38; 43], [71; 69], 'VariableNames', {'Age', 'Height'});
filename = fullfile (tempdir (), 'patients.ods');
table2ods (T, filename);
ods2table (filename)
ans =
2x2 table
Age Height
___ ______
38 71
43 69
Point 'Sheet' at a specific sheet, by name or by 1-based index, to read one page of a multi-sheet workbook.
filename = fullfile (tempdir (), 'workbook.ods');
table2ods (table ([38; 43], 'VariableNames', {'Age'}), filename, 'Sheet', 'Patients');
table2ods (table ([1; 2; 3], 'VariableNames', {'Visit'}), filename, 'Sheet', 'Visits');
ods2table (filename, 'Sheet', 'Visits')
ans =
3x1 table
Visit
_____
1
2
3
delete (filename);