Wed 08 Jul 2015 08:10:04 PM UTC, original submission:
xlswrite can be used after installing the io-package with:
pkg install io-2.2.8.tar.gz
The io-2.2.8.tar.gz file has to be located in the Octave working directory. Then
pkg load io
has to be entered.
The following bugs with xlswrite are observed:
1) writing a second Excel-sheet to an existing file with
xlswrite('filename.xlsx', arr, 2, 'B2:Z100')
will result in an error. If filename.xlsx does not exist, the Excel-file is created with "Sheet2" as first table. In order to add a second sheet to an existing file, the sheet-name has to be written explicitly with apostrophes:
xlswrite('filename.xlsx', arr, 'Sheet3', 'B2:Z100')
2) Small numbers in array arr will lose precision, when written to the Excel-file. Numbers below 1e-12 are written as 0 to the file. For an array of small numbers all information is lost.
3) When an Excel-file is newly created by xlswrite it must not exist. An error results, if an Excel file, e.g. 'filename.xlsx', exists in the starting directory of the Octave-run, although the program has changed to a sub-directory where no such file exists and where the file has to be created.
Here is an example of program execution with Octave 4.0.0 for bug 1):
>> arr=rand(3,4); xlswrite('filename.xlsx',arr,1,'B2:Z100')
Detected XLS interfaces: ans = 1
>> xlswrite('filename.xlsx', arr, 2, 'B2:Z100')
error: 'string' undefined near line 127 column 19
error: called from
_OCT_oct2xlsx_ at line 127 column 7
_OCT_oct2spsh_ at line 74 column 18
oct2xls at line 207 column 18
xlswrite at line 218 column 20
error: evaluating argument list element number 1
error: called from
_OCT_oct2xlsx_ at line 127 column 7
_OCT_oct2spsh_ at line 74 column 18
oct2xls at line 207 column 18
xlswrite at line 218 column 20
An example for bug 2) is provided below:
arr=rand(3,4); xlswrite('filename.xlsx',arr,1,'B2:Z100')
xlswrite('filename.xlsx', arr*1e-4, 'Sheet2', 'B2:Z100')
xlswrite('filename.xlsx', arr*1e-12,'Sheet2', 'B6:Z100')
This sequence of commands leads to an Excel file 'filename.xlsx' with the original array arr in Sheet1 and scaled arrays arr with lost precision in Sheet2.
In order to be compatible with Matlab syntax, it would also be desirable not to restrict the array to the cell region specified in xlswrite. E.g. in Matlab xlswrite('filename.xlsx',arr,1,'B2') writes the full array arr starting at B2 as upper left cell. Octave only writes the first element of arr to B2. However, different program runs can create different sizes of array arr. In that case the Matlab syntax is more convenient. As a workaround it is possible in Octave to give a cell region larger than the extension of arr, but this does not lead to a generally valid programming technique.
|