Function File: xls = xlsopen (filename)
Function File: xls = xlsopen (filename, readwrite)
Function File: xls = xlsopen (filename, readwrite, reqintf)
Function File: xls = xlsopen (filename, readwrite, reqintf, verb)

Get a pointer to a spreadsheet in memory in the form of return argument (file pointer struct) xls.

Calling xlsopen without specifying a return argument is fairly useless and considered an error! After processing the spreadsheet, the file pointer must be explicitly closed by calling xlsclose() to release possibly large amounts of RAM.

filename should be a valid spreadsheet file name (including extension); see "help xlsread" for an overview of supported spreadsheet file formats.

If readwrite is set to 0 (default value) or omitted, the spreadsheet file is opened for reading. If readwrite is set to true or 1, a spreadsheet file is opened (or created) for reading & writing.

Optional input argument reqintf can be used to override the spreadsheet I/O interface (see below) that otherwise would automatically be selected by xlsopen. In most situations this parameter is unneeded as xlsopen automatically selects the most useful interface present, depending on installed external support software and requested file type. A user-specified interface selection can be reset to default by entering a numeric value of -1.

If a value of 1 or true is entered for verb, xlsopen returns info about the spreadsheet I/O interfaces that were found and/or are requested and active. The default value is false (no info on interfaces is shown).

xlsopen works with interfaces, which are links to support software, mostly external.
The built-in ’OCT’ interface needs no external software and allows I/O from/to OOXML (Excel 2007 and up), ODS 1.2 and Gnumeric.
For all other spreadsheet formats, or if you want more speed and/or more flexibility, additional external software is required. See "help xlsread" for more info.
Currently implemented interfaces to external SW are (in order of preference) ’COM’ (Excel/COM), ’POI’ (Java/Apache POI), ’JXL’ (Java/JExcelAPI), ’OXS’ (Java/OpenXLS), ’UNO’ (Java/OpenOffice.org - EXPERIMENTAL!), ’OTK’ (ODF Toolkit), ’JOD’ (jOpendocument) or ’OCT’ (native Octave); see below:

xls and .xlsx:

One or more of (1) a Java JRE plus Apache POI >= 3.5, and/or JExcelAPI and/or OpenXLS, and/or OpenOffice.org (or clones) installed on your computer + proper javaclasspath set, or (2 - Windows only) OF-windows package and MS-Excel. These interfaces are referred to as POI, JXL, OXS, UNO and COM, resp., and are preferred in that order by default (depending on presence of the pertinent support SW). Currently the OCT interface has the lowest priority.
Excel’95 spreadsheets (BIFF5) can only be read using the JXL (JExcelAPI), UNO (Open-/LibreOffice), and COM (Excel-ActiveX) interfaces.

.ods, .sxc:

A Java JRE plus one or more of (ODFtoolkit (version 0.7.5 or 0.8.6 - 0.8.8) & xercesImpl v.2.9.1), jOpenDocument, or OpenOffice.org (or clones) installed on your computer + proper javaclasspath set. These interfaces are referred to as OTK, JOD, and UNO resp., and are preferred in that order by default (depending on presence of support SW). The OCT interface has lowest priority).
The old OpenOffice.org .sxc format can be read using the UNO interface and older versions of the JOD interface.

Other formats:

Apart from .gnumeric, by invoking the UNO interface one can read any format that the installed LibreOffice version supports. The same goes (on Windows systems) for MS-Excel. However, writing to other file formats than .xlsx, .ods, .gnumeric and .xls is not implemented.

The utility function chk_spreadsheet_support.m can be useful to set the javaclasspath for the Java-based interfaces.

Beware: ’zombie’ Excel invocations may be left running invisibly in case of COM errors or after forgetting to close the file pointer. Similarly for LibreOffice, which may even prevent Octave from being closed (the reason the UNO interface is still experimental).

Examples:

  xls = xlsopen ('test1.xls');
  (get a pointer for reading from spreadsheet test1.xls)

  xls = xlsopen ('test2.xls', 1, 'POI');
  (as above, indicate test2.xls will be written to; in this case using Java
   and the Apache POI interface are requested)

See also: xlsclose, xlsread, xlswrite, xls2oct, oct2xls, xlsfinfo, chk_spreadsheet_support.

Package: io