help-octave
[Top][All Lists]
Advanced

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

Re: XLSWrite


From: Philip Nienhuis
Subject: Re: XLSWrite
Date: Wed, 13 Oct 2010 12:11:32 -0700 (PDT)


Ian Journeaux-2 wrote:
> 
> Ok making progress but getting the XLS interface to work in Octave is not
> the most obvious thing in the world.
> 
> 

Some is covered in the octave-windows 3.2.4 binary's README.txt. Should be
somewhere in the root of your octave installation.
The "clear all" bug is mentioned in the KNOWN-ISSUES.txt, also in the octave
root folder.

Spreadsheet support is supposed to work out-of-the-box, that is: after doing
pkg load windows
pkg load java
(in Octave)
Admittedly that may not be very clear - the connection between these (vital)
statements for the octave 3.2.4 windows binary and complete spreadsheet
support is apparently not explicitly mentioned. Good to know.
Hopefully the Octave-Windows package maintainer will improve this text (I'll
send him some suggestions).



> Finally figured out how to get JExcelAPI installed. I followed the steps
> at
> 
> 
> http://forums.sun.com/thread.jspa?threadID=5222024 
> 

That shouldn't have been needed at all. Everything is supposed to be
pre-installed...



> This seems to allow writing to a pre existing xls file but if the file
> doesn't exist, I get some error messages
> 
> octave-3.2.4.exe:2> xlswrite("c:/test2.xls", a)
> ncols =  256
> Creating file c:/test2.xls
> Supported interfaces:  Excel (COM) OK. warning: split is obsolete and will
> be removed from a future version of Octave Use strsplit instead
> Java/Apache (POI) OK. (& OOXML OK)   Java/JExcelAPI (JXL) OK.
> 

All this means that you got Windows pkg + Excel installed and loaded OK.
Contrary to what you might think, the spreadsheet scripts pick "COM" (=
ActiveX, IOW a hidden Excel invocation), not JExcelAPI, because COM is the
first Excel interface found. The other two (java-based ones, POI & JXL) are
also OK but are not invoked.
You could also try

xlswrite ("c:\test3.xls", a, 'poi')

or

xlswrite ("c:\test3.xls", a, 'jxl')

(note backward slash!)



> error: com_invoke: property/method invocation on the COM object failed
> with
> error `0x80020009'
> error: called from:
> error:  
> C:\Octave\3.2.4_gcc-4.4.0\share\octave\packages\io-1.0.11\oct2xls.m
> at line 290, column 3
> error:  
> C:\Octave\3.2.4_gcc-4.4.0\share\octave\packages\io-1.0.11\oct2xls.m
> at line 86, column 17
> Saving file c:/test2.xls ...
> error:
> C:\Octave\3.2.4_gcc-4.4.0\share\octave\packages\io-1.0.11\xlswrite.m at
> line
> 160, column 6
> 

These COM errors are unknown to me. What's in your array a?

The write error might be related to the forward slash in the file name
(you're running octave under windows, don't you?)



> Even with the errors, the xls file gets created. A second call to xlswrite
> with the same file name doesn't produce an error.
> 

(Is the Excel file OK?)

Under windows you should use backslashes when accessing files (Excel.exe,
which is magically invoked behind the scenes, wouldn't know what to do with
forward slashes)...

BTW in svn there's a troubleshooting section in the docs, see:
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/io/doc/READ-XLS.html?revision=7842
for the latest version.

And, in your first post IIRC you mentioned you want to add several
worksheets to one Excel file; better use an xlsopen - xls2oct-xls2oct -
..... - xlsclose sequence as per the docs rather than repeated xlswrite.
Each xlswrite call will start and close down Excel, the aforementioned
sequence will do that only once for many worksheets (and you can mix reading
& writing).

Be careful with JExcelAPI, I do not trust it completely when writing to
existing spreadsheets. It seems it doesn't allow writing multiple worksheets
consecutively in an xlsopen-oct2xls-oct2xls-xlsclose sequence (reading is OK
though). A.o. because of that it's the least preferred (= last tested)
option, and because Apache POI is much more versatile.

Philip
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/XLSWrite-tp2993033p2994276.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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