octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xlsread in Octave 3.6.4


From: Philip Nienhuis
Subject: Re: xlsread in Octave 3.6.4
Date: Mon, 21 Oct 2013 00:16:31 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6

Markus:

(sorry for long post.
Only of value for those interested in OOXML spreadsheet I/O)

Markus wrote:
Am 2013-10-04 14:50, schrieb Philip Nienhuis:
I'll start but it's not finished.
I've pushed my commits i made last week, but it's broken and now it
beats me.

xlsread('../../example/excel2010.xlsx', 1, [],{'OCT'})
Checking requested interface(s):
OCT*; (* = default interface)
error: cellfun: C must be a cell array
error: called from:
error: /home/markus/Downloads/newxlsxread/io/inst/xls2oct.m at line 219,
column 11
error: /home/markus/Downloads/newxlsxread/io/inst/xlsread.m at line 199,
column 22

Perhaps you have time to take a look at it. But I'm busy till sunday again.

Right, most of your xlsxread code (except for some small stanzas) has now been incorporated in the io package and committed to svn.

What I've done today, in addition to your work:

- Transferred some code that referred to worksheet detection
  from __OCT_spsh_open__.m to __OCT_xlsx2oct__.m;
- Replaced about half of that code in __OCT_xlsx2oct__.m;
- Added some code to detect occupied cell ranges to __OCT_xlsx2oct__.m;
- Reintroduced the 'xls' file pointer struct to the call to
  __OCT_xlsx2oct__ in xlsopen.m. This is needed as this pointer
  contains the detected cell range limits needed further down in
  xlsopen;
- At the bottom of __OCT_xlsx2oct__.m, morph the numeric data array
  into a cell array;
- Added some code to __OCT_spsh_info__ for roughly inferring occupied
  cell ranges (the info that Excel itself puts there);
- Completed __OCT_spsh_close__.m
- Some more small stuff, I forgot;
- Lots of testing.

I took care to stay away from your regexp() wizardry ;-)

It all seems to works fine (and FAST! yesss) with most of your and mine test spreadsheets, save these two: - Your example.xlsx is too big for my box (it has only 2 GB RAM). I'll try later this week on my laptop (8 GB RAM). - testOOXML.xlsx: worksheets #3 and #7 of file testOOXML.xlsx yield errors (I hope you can fix them this coming week), see transcript below:

=======================================================
octave:4> xls = xlsopen ('testOOXML.xlsx', 0, 'oct')

octave:5> [raw, xls] = xls2oct (xls, 3); size (raw)
error: reshape: SIZE is not divisible by the product of known dimensions (= 7)
error: called from:
error: X:\Octave\Octave3.6.4_gcc4.6.2\share\octave\packages\io-1.2.4\private\__OCT_xlsx2oct__.m at line 127, column 8
<snip>

octave:6> [raw, xls] = xls2oct (xls, 7); size (raw)
warning: implicit conversion from matrix to sq_string
warning: implicit conversion from matrix to sq_string
error: __OCT_xlsx2oct__: A(I) = X: X must have the same size as I
error: called from:
error: X:\Octave\Octave3.6.4_gcc4.6.2\share\octave\packages\io-1.2.4\private\__OCT_xlsx2oct__.m at line 124, column 13
<snip>

===================================================
As for the other sheets: xls = file pointer using OCT, xlsu = file pointer using LibreOffice (UNO/Java, absolutely reliable):

octave:17> [raw, xls] = xls2oct (xls, 1); size (raw)
ans =
    8   29
octave:18> [raw, xlsu] = xls2oct (xlsu, 1); size (raw)
ans =
    8   29
(==> Correct)

octave:19> [raw, xls] = xls2oct (xls, 2); size (raw)
ans =
     31   1024
octave:20> [raw, xlsu] = xls2oct (xlsu, 2); size (raw)
ans =
     36   1024
(xlsxread misses 5 rows)

octave:22> [raw, xls] = xls2oct (xls, 4); size (raw)
ans =
   12    5
octave:23> [raw, xlsu] = xls2oct (xlsu, 4); size (raw)
ans =
   13    5
(Ambiguous. The lower row that xlsxread misses contains results from a deliberately erroneous spreadsheet formula (#N/A). Let's just declare this behavior correct)

octave:24> [raw, xls] = xls2oct (xls, 5); size (raw)
ans =
   3   2
octave:25> [raw, xlsu] = xls2oct (xlsu, 5); size (raw)
ans =
   3   2
(==> Correct)

octave:26> [raw, xls] = xls2oct (xls, 6); size (raw)
ans =
    8   10
octave:27> [raw, xlsu] = xls2oct (xlsu, 6); size (raw)
ans =
    8   10
(==> Correct)

=====================================================
...and for completeness the LibreOffice / UNO results from the sheets that xlsxread cannot read:

octave:21> [raw, xlsu] = xls2oct (xlsu, 3); size (raw)
ans =
    7   12
octave:28> [raw, xlsu] = xls2oct (xlsu, 7); size (raw)
ans =
   11   13


Thank you very much for your contribution, Markus.

I'll be away til Monday 28. I'll work on the docs in the mean time and prepare an io-1.2.4 release for stable Octave (and hopefully io-2.0.0 for Octave > 3.7.1).

Philip


reply via email to

[Prev in Thread] Current Thread [Next in Thread]