Hi Ramon,

(FYI I've cc'd the octave-dev mailing list as other people might benefit 
from this thread too. Pls answer using "reply all".)

Ramon Bueno wrote:
> Hi
>
> In  between meetings I managed to remove and reinstall Octave, this time
> noting and selecting all the packages explicitly except, as you
> suggested, oct2mat.
>
> All seems to have installed fine and the "pkg list" command shows a
> whole list, including *io*.  I
>
> then copied the MatLab code I'm trying to run and the xls files it reads
> into the *C:\Octave\3.2.4_gcc-4.4.0\bin *directory (to keep things as

Hmmm.... I think this is a bad idea in general (IMO it's one of the less 
bright habits associated with Matlab, to have users dump all kind of 
stuff into .\bin. It's really much better to separate native program 
package stuff and stuff from other sources ).

Please make a subdirectory in e.g., your My Documents subdir to store 
the Matlab scripts and add the following lines to your "octaverc" file, 
which lives here:
    <octave-dir>\share\octave\3.2.4\m\startup\octaverc
(it's a plain text file, be sure it stays to be called octaverc 
*without* suffix)
above the final "atexit ()" call at the bottom:

-----------<cut>-------------

## Load windows package (only needed for 3.2.4)
pkg load windows

## Go to script directory
cd 'C:\Documents and Settings\<yourname>\My Documents\<your Matlab 
script directory>'

## Add script directory to path
addpath ('C:\Documents and Settings\<yourname>\My Documents\<your Matlab 
script directory>')

-----------</cut & paste>----

(note the quotes, each command on one line)

and restart Octave.

BTW if you're really neat you could enter a line

pkg unload windows

in the file __finish__.m, as first command above the if-endif block. 
It's in the same subdir as octaverc.

(All this pkg load/unload windows is needed because octave *can* crash 
on exit when the windows package is loaded (i.e., a bug workaround).
I applied this to my PC at the office where this was needed and it works 
OK; but on my home PC + laptop it wasn't needed.)


> simple as possible) and get this message now:
>
> Supported interfaces:
>
> warning: No support for Excel .xls I/O
>
>   Error XLSREAD: reading EXCEL .xls file (BIFF-Format) isn't supported
> on this system.

This message means xlsread cannot find any usable Excel interface.

So, for some traceback:

1. You got the windows package installed. That means that the only 
conceivable things lacking for ActiveX/COM (= hidden MS-Office server) are:
- a *loaded* windows package (! yeah this is a gotcha on octave-3.2.4)
   (This might be the problem. Pls check if "pkg list" returns an 
asterisk "*" before the windows package version. If not, do a "pkg load 
windows" and retry)
- an installed Excel (part of MS-Office I mean). Have you got Excel?

2. When no COM interface is found, xlsread (actually its support routine 
xlsopen) falls back to Java interfaces.

3. Now, if you have installed a complete octave package as you said you 
did, all java based octave spreadsheet stuff (i.e. the java classes) has 
been installed (just check in <octave>\bin for e.g, poi-<blah-blah>.jar 
or jxl.jar) - *except* the java runtime (JRE or JDK) proper which you 
must install yourself (or your IT dept. probably / hopefully installed).
(Ah and java should have been loaded too - check for the asterisk in the 
java-<version> line in the "pkg list" output. If not present, do "pkg 
load java". But unlike the windows package, the java package should have 
been loaded by default.)

4. From the messages I conclude that xlsread doesn't find any usable 
Java interface. So I conclude you have no working Java either; or maybe 
too old a version (Java should be at 1.5 or -very preferrably- 1.6).

In conclusion, xlsread's messages say it has found no Excel interfaces 
at all, so there's no .xls support.

Or, did you install octave into a directory with spaces in the name? 
(e.g., 'C:\Program Files\octave-blah-blah') - that is known to make for 
interesting problems.
In the installation docs (README etc) it should be outlined that this is 
not advised.


OK, cd (in octave) to the directory where you keep your .xls file (NOT 
in <octave>\bin!!), and then please try these commands in succession 
(without ending semicolon):

exl = actxserver ('Excel.Application')

delete ('exl')

xls1 = xlsopen ('<your .xls file name>, 0, 'com')

xlsclose (xls1)


tmp = java_new ('java.lang.String', 'abc')

javaclasspath

xls2 = xlsopen ('<your .xls file name>, 0, 'poi')

xlsclose (xls2)

xls3 = xlsopen ('<your .xls file name>, 0, 'jxl')

xlsclose (xls3)

and report back what messages you got.


The first four are checks on COM/ActiveX.
If command #1 works don't forget command #2, similarly for commands #3 & 
#4.
OTOH if command #1 doesn't return a COM object you can retry after "pkg 
load windows" and if that doesn't help either, skip directly to the 
tmp=java_new command as COM is faulty.

The fifth is a test for a working java installation.
If it doesn't report something like "tmp = abc" and yields errors 
instead, you can skip the rest as in that case Java doesn't work at all.

(Not for you Ramon, but for other people struggling with Excel issues:)
If upon trying command #6 (..., 'poi') you get errors like "unrecognized 
file format" or so, do try the next interface as POI cannot read BIFF5 
(Excel '95) but JXL (and of course, COM) can.

<snip>
> Since the xls file has several worksheets it reads with XLSREAD commands
> such as these, if I can't make it work I can try saving each sheet to
> its own CSV and modify each statement to reach the particular CSV using
> DLMREAD...?  I am running under Windows 7, but the input Excel files are
> xls (i.e., *Excel 97-2003* workbook format).  I'm not sure if I need
> additional Windows components that I'm not familiar with (like the
> discussion on COM vs. Java).  I am supposed to download/install the .NET
> Framework for another application, will that help?

No, .NET has no business at all with Octave & vice versa.

Let's first try to get octave's (actually, octave-forge's) Excel stuff 
to work OK. IMO csvread etc is really a last resort. I didn't write the 
spreadsheet scripts to surrender to csvread & friends too soon... :-)
Good luck,

Philip

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to