LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Container and excel

I have create an archive of some measurement in an excel worksheet with
activeX. I want to view this archive without open excel. I want to use
a container: but only a part of the worksheet is visible on the screen.
I try to add scrollbar but I didn't find a good documentation how to
use containers (there aren't a lot of documentation in the NI's
manuels). Can someone help me?

Thomas


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 1 of 3
(3,293 Views)
> I have create an archive of some measurement in an excel worksheet with
> activeX. I want to view this archive without open excel. I want to use
> a container: but only a part of the worksheet is visible on the screen.
> I try to add scrollbar but I didn't find a good documentation how to
> use containers (there aren't a lot of documentation in the NI's
> manuels). Can someone help me?
>

I'm afraid that you will find this a little difficult to achieve, especially
if the Excel sheet is saved as binary. It is possible to implement a reader
for Excel worksheets, but the standard for them changes pretty often,
and it
is much easier to exchange data through tab delimited spreadsheet files,
or ask
them to read their binary format and return the data through ActiveX.
I
f you
can find VIs for directly parsing the information from an Excel file, then
much of the job is done, and you just need to place the data into a LV table
control.

The container at first sounds like it will take care of all this, but, there
is no Excel control for displaying worksheets, at least not one from
MS, and
I'm not aware of a third party one. You can embed a document into the container,
but I think you will find that it isn't what you expect. The document
link is
a picture of the document, and a link to get to Excel from the picture. An
OCX, or control is an interactive object, and it would be super for PowerPoint,
Excel, and Word to put all of their functionality into an OCX, but
again, that
isn't what they do.

Again, Excel is a great place to log data if you allow for it to be
around when
you want to retrieve the data. Or, you can have Excel or almost
anything else
save into a tab-delimited file that is very portable and most anything
can read
from.

Greg McKaskle
0 Kudos
Message 2 of 3
(3,292 Views)
I'm writing this partially from memory, so no guarantees, but,
if you have Excel installed on your machine,
this is how you do it with ActiveX (or pretty close, anyway):
(1) Place an automation refnum on the front panel.
(2) Right click on the automation refnum, choose browse, and select the excel object
library.
(3) Choose 'Application'. Go to the block diagram.
(4) Get the Communication>>ActiveX palette up and thumb-tack it so it stays visible.
(5) Place an 'automation open' on the diagram and wire the automation refnum to it.
(6) Wire the output side to a property node - select the Workbooks property.
(7) Wire the output of that to an invoke node - select the 'Open' method.
(You'll need the excel help file to figure out what to wire to the various elements
of this node).
You now have a handle to the workbook (your file).
(8) Wire the output side of the 'Open' element to another property node.
(9) Select the worksheets property.
You now have a handle to the 'worksheets collection' - an array maintained by Excel.
(10) Wire this to an invoke node and select the 'Item' method - this indexes the
array.
(11) Wire a number to the 'Index' element to select the sheet by number.
(12) Now the trick - place a second automation refnum on the front panel.
Right click on it and browse again, get the excel object library, but this time
choose 'Worksheet'.
(13) Go back to the diagram, and place a 'To G data' function.
(14) Wire the worksheet automation refnum to the 'type' input of the 'to G data'
function.
(15) Wire the output of the 'item' element (from the previouos invoke node) to the
'to G data' function.
The output side of the 'to G data' function is now a worksheet handle.
Almost done.
(16) Go get another invoke node, and select 'Range'.
Check the Excel examples provided by NatInst to see what to wire to this range node.
(Its some kind of row-column specifier, but I don't recall the exact format).
(17) Finally, wire the output of the Range element to a property node, and select
'Value'.
If I remember correctly, the output of this last property node is a 1D or 2D array,
depending on what range was specified. (Not real sure about this).
(18) Use one more 'to G data' conversion with the desired data type (2D array?) wired
to its type specifier, and you're done.
(*) Don't forget to close all the refnums (or pointers, or handles, or whatever)
using 'automation close'.
If you fail to close all the refnums every time the VI is run, Windows will be very
unhappy !!
(**) If you don't want to see Excel opening up, there is a 'visible' property that
can be
set at the Excel_application level. Have fun but don't stay up as late as I just
did.
-V.R.

> > I have create an archive of some measurement in an excel worksheet with
> > activeX. I want to view this archive without open excel. I want to use
> > a container: but only a part of the worksheet is visible on the screen.
> > I try to add scrollbar but I didn't find a good documentation how to
> > use containers (there aren't a lot of documentation in the NI's
> > manuels). Can someone help me?
> >
>
> I'm afraid that you will find this a little difficult to achieve, especially
> if the Excel sheet is saved as binary. It is possible to implement a reader
> for Excel worksheets, but the standard for them changes pretty often,
> and it
> is much easier to exchange data through tab delimited spreadsheet files,
> or ask
> them to read their binary format and return the data through ActiveX.
> If you
> can find VIs for directly parsing the information from an Excel file, then
> much of the job is done, and you just need to place the data into a LV table
> control.
>
> The container at first sounds like it will take care of all this, but, there
> is no Excel control for displaying worksheets, at least not one from
> MS, and
> I'm not aware of a third party one. You can embed a document into the container,
> but I think you will find that it isn't what you expect. The document
> link is
> a picture of the document, and a link to get to Excel from the picture. An
> OCX, or control is an interactive object, and it would be super for PowerPoint,
> Excel, and Word to put all of their functionality into an OCX, but
> again, that
> isn't what they do.
>
> Again, Excel is a great place to log data if you allow for it to be
> around when
> you want to retrieve the data. Or, you can have Excel or almost
> anything else
> save into a tab-delimited file that is very portable and most anything
> can read
> from.
>
> Greg McKaskle
0 Kudos
Message 3 of 3
(3,292 Views)