[xls] = xlsclose (xls) ¶[xls] = xlsclose (xls, filename) ¶[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 COM interface was used- ActiveX/Excel will be closed. With managed UNO
transport, the opened document is closed; a LibreOffice listener that
Octave started is kept for reuse until the io package is unloaded, while an
existing LibreOffice desktop session is left running. With legacy
Bootstrap transport, the LibreOffice/OpenOffice.org process is terminated.
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) 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/OpenOffice.org, 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)
Package: io