<< odstoolbox odstoolbox Utilities >>

odstoolbox >> odstoolbox > odsRead

odsRead

Read data from a LibreOffice or OpenOffice OpenDocument spreadsheet file (.ods)

Syntax

data = odsRead(filename)
data = odsRead(filename, "sheet", sheet_value)
data = odsRead(filename, "range", range_value)
data = odsRead(filename, "conversion", conversion_type)
data = odsRead(filename, option1, value1, option2, value2, ...)

Parameters

filename:

String contains the filename incl. full or relative path

"sheet", sheet_value:

String or positive integer contains sheet name or sheet index. Default = 1 [Optional]

"range", range_value:

String or 2x2 matrix Excel-style cell range. Details refer description below. Default = all cells of a sheet [Optional]

"conversion", conversion_type:

String, "double" = numeric matrix. "string" = string matrix. "cell" = cell array containing mixed data, Default = "double" [Optional]

data:

NxN matrix of doubles, cells or strings imported from the ODS-file

Description

Read data from a LibreOffice/OpenDocument Spreadsheet (.ods) file using an interface similar to xlsxRead() introduced in Scilab 2026.1.0 and stores it in a matrix of doubles, strings or cells.

filename:

Must be a string which contains the full path incl. full filename or a relative path. E.g. "C:\Users\Me\Documents\Data\Experiment 1.ods" or "../../data/experiment1.ods". On Unix(-like) systems the path is case sensitive.

Options are specified in pairs. First, the option is enclosed in quotation marks, followed by a comma and the corresponding value.

"sheet":

By default, the program reads from the first sheet. Specify the sheet name or the sheet index. E.g. "sheet", "name of the sheet" or "sheet", 1. Where 1 is the sheet index (1st sheet). The sheet name must be a string, the sheet index a positve integer.

"range":

odsRead reads the whole sheet by default. Specify an Excel-like cell range as a string, e.g. "A1:C10", "A:C", "1:10", "B5" or a 2x2 numeric matrix [startRow startColumn ; endRow endColumn], e.g. [1 1 ; 10 3]. That is equal to "A1:C10"

conversion:

If no conversion mode is specified, all data is converted to double values; non-numeric values become %nan. If “string” is selected, a matrix of strings is returned; if “cell” is passed, a cell array matrix with possible mixed data is returned.

Some examples:

How odsRead works:

The ODS file is temporarily converted to XLSX format using LibreOffice or OpenOffice in headless mode and then imported using “xlsxRead” from Scilab 2026.1.0 or later. When using Scilab versions 2025 or earlier, “xlread” from the “xlreadwrite” toolbox is used.

The conversion from OpenDocument (*.ods) to OpenXML (*.xlsx) via LibreOffice is time consuming. PLEASE BE PATIENT!

Authors


Report an issue
<< odstoolbox odstoolbox Utilities >>