Function File: [xls] = xlsclose (xls)
Function File: [xls] = xlsclose (xls, filename)
Function File: [xls] = xlsclose (xls, "FORCE")

Close a spreadsheet file pointed to in struct xls, and if needed write file to disk.

xlsclose will determine if the file should be written to disk based on information contained in xls. If no errors occured during writing, the xls file pointer struct will be reset to empty and -if the UNO or COM interface was used- LibreOffice (or OpenOffice.org) or ActiveX/Excel will be closed. However if errors occurred, the file pointer will be untouched so you can clean up before a next try with xlsclose().
Be warned that until xlsopen is called again with the same xls pointer struct, hidden Excel or Java applications with associated (possibly large) memory chunks are kept in memory, taking up resources. If (string) argument "FORCE" is supplied, the file pointer will be reset regardless, whether the possibly modified file has been saved successfully or not. Hidden Excel (COM) or LibreOffice.org (UNO) invocations may live on, possibly even impeding proper shutdown of Octave.

filename can be used to write changed spreadsheet files to a file other than that opened with xlsopen(); unfortunately this doesn’t work with JXL (JExcelAPI) interface.

For other file formats than OOXML, ODS or gnumeric, you need a Java JRE plus Apache POI > 3.5 and/or JExcelAPI, OpenXLS, jOpenDocument, ODF Toolkit and/or LibreOffice or clones, and/or the OF windows package + MS-Excel installed on your computer + proper javaclasspath set, to make this function work at all.

xls must be a valid pointer struct made by xlsopen() in the same octave session.

Examples:

  xls1 = xlsclose (xls1);
  (Close spreadsheet file pointed to in pointer struct xls1; xls1 is reset)

See also: xlsopen, xlsread, xlswrite, xls2oct, oct2xls, xlsfinfo.

Package: io