help-octave
[Top][All Lists]
Advanced

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

Re: Using COM interface to write to Excel


From: PhilipNienhuis
Subject: Re: Using COM interface to write to Excel
Date: Thu, 5 Jul 2012 08:36:55 -0700 (PDT)

Michael Goffioul wrote
> 
> On Wed, Jul 4, 2012 at 11:41 PM, BinaryGirl <eamarasco@> wrote:
> 
>> Hello,
>>
>> I have a Matlab program that I am trying to run in Octave.  While the
>> majority of my program runs smoothly, I'm having a few problems with the
>> COM
>> interface.  I have installed both the i/o and windows packages, and my
>> program runs fine with the few trouble lines commented out.
>>
>> The problem is basically that I can read from the Excel file, but I can't
>> write any data back.
>>
>>
>> For example, this line of code works fine:
>>
>> storageName = infoSheet.Range('B7').Value;
>>
>>
>> However, when I want to write the same variable to a different worksheet
>> in
>> the same workbook (yes, I created a handle to the worksheet already), the
>> following line causes an error:
>>
>> addInfoSheet.Range('B1').Value = storageName;
>>
>>
>> This line of code worked fine in Matlab, so I'm under the impression that
>> Octave just doesn't support this particular command.  Is there a way I
>> can
>> write data back out to my Excel file while it's still open using the COM
>> interface?  Or is my only option to close the actxserver and then re-open
>> the file using xlsopen and xlswrite?
>>
> 
> Writing XLS files was definitely working when I wrote that code.
> 

Don't worry, it is still working :-)



>  For
> instance, the example file in the Windows package is writing an Excel file
> [1]. Could you try this instead:
> 
> r = addInfoSheet.Range('B1')
> r.Value = storageName;
> 
> Michael.
> 

To the OP:

1. This rather belongs in Octave-Forge ML
(address@hidden). I can't cc them from Nabble so would you
please also reply to that e-mail address?

2. If you want I can look into this tonight or tomorrow night. But I need
more info then.

One possible issue:

Some time ago I've reported somewhere (octave-forge ML? this ML? I don't
remember) that most spreadsheets internally only support double, logical
("boolean") and character string types. All other types you see (dates, ...)
are actually cooked-up types based on the cell formatting.
Now, Octave's COM interface (and for that matter, ML's as well) will error
out if you try to write single, integers and unsigned integer values (any
bit width). It simply hasn't been made robust enough (by M$).

Could that be the issue you have?

FYI  I've patched this "bug" (or limitation) a few weeks ago in svn.
(ML's xlswrite already seems to catch this and converts numeric values into
double (I just tried with 2007a and 2012a)

Philip


--
View this message in context: 
http://octave.1599824.n4.nabble.com/Using-COM-interface-to-write-to-Excel-tp4631222p4631234.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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