From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel & ActiveX: Insert arbitrary columns from 2D array and create graph problems

Solved!
Go to solution

Hi there,

 

I want to insert data from either a 1D or 2D array from LabView into Excel and create graphs.

 

I used the information from the following example:

 

http://www.ni.com/example/28934/en/

 

and was able to create a new Excel file (I'm using Excel 2010), writing data from an 1D array to a column in excel by creating a while loop and using the first element of the array to write it to a specific cell. I use the counter of the loop to write to the next cell when the loop starts over and always delete the first value, which I write to the cell, from the array until it is empty.

 

Now I also would like to write a 2D array - so the first column in Excel should be the first column from the array and so. Here I cannot use the loop counter directly as Excel only counts 1,2,... for the rows, but uses A,B,... to count columns. Also I do not know in advance how many columns my 2D array will contain, so creating a lookup table like (A means 1, B means 2,...) is not really an option (except there really is no other way). Is there a possibilty to convert numbers into letters or some way to 'explain' to the program that column 2 in the array means column B in Excel for example, or is there a way to insert new columns?

I figured out how to add new Worksheets and as I also need to create a certain number of Worksheets and I know that on standard 3 sheets are present when creating the file, I use the 'add' methode to create every new worksheets before worksheet 3 - I could use the same methode to create new columns in Excel, but so far I didn't find a methode to do so. Or is there a way to enter the whole 2D array at once?

 

Then I'd like to create a graph (in case of the 1D arrays a bar plot, when using 2D arrays a 3D plot) to view the data. I found this example:

 

http://www.ni.com/newsletter/51339/en/

 

-> as I do not have the toolkit I'd like to do it using ActiveX directly, so I tried to do things like shown under the headline 'DIY ActiveX/.NET'

 

I tried to load the snippet to a new Excel file but got the error message 'microsoft.office.interop.excel.dll not found' and hence the code is not working. That confuses me a little as I would guess when this dll is not present I cannot access Excel from LabView at all, though my understanding of what I'm really doing so far is quiet limited. 😉

 

Also - as far as I understand from the snippet - when creating a new chart object I should be able the create methodes for it, however when I do a right click on the chart object of an ActiveX Worksheet symbol there are none listed.

 

To explain my problems better I added a snippet showing my two problems: The inner of the two while loops shows how I import a 1D array. In the outer loop I seperate the columns. I know that currently this is not working as all data end up in column A of the Excel sheet - so I would need to convert the number of the outer counter to A, B,... or find a different solution.

 

Moreover on the snippet I placed an ActiveX Worksheet Property with the Chart Object - as I can see the difference to the Chart Object in the example code from the last link above is the color. However I'm not sure what that means and how to change/ solve this.

 

And just to make sure - I know this way the VI does not run as the Chart Object is placed completely wrong - I just did it, so it is included in the snippet.

 

I'd be thankful for any suggestions,

Thanks!

0 Kudos
Message 1 of 7
(3,895 Views)

I started using LabVIEW with LabVIEW 7.0, where the Office Toolkit involved using ActiveX for Excel.  When I tried to migrate to Office 2010, Windows 7, and LabVIEW 8.x, I abandoned ActiveX (very hard to find support for it in Windows 7) and started using the Report Object in the Report Generation Toolkit.  It is so much easier than ActiveX ...

 

BS

0 Kudos
Message 2 of 7
(3,879 Views)

Hello to all,

 

the Report Generation Toolkit is integrated in LabVIEW 2014 professional edition.

 

Here is a link that should help you to write the 2D Array

I want to write 2D array to specific columns/ro​ws in excel

 

Here is a link for creating a graph

Create via ActiveX Labview a XY Scatter plot graph on an excel sheet

 

Hope it helps, if not please let me know.

best regards
Alexander
0 Kudos
Message 3 of 7
(3,809 Views)
Solution
Accepted by topic author MrTheBrain

Hello to all

 

for your information in LabVIEW 2014 professional the report genertion toolkit is included

 

2D Array

I want to write 2D array to specific colums/rows in excel

 

Graph

Create via ActiveX Labview a XY Scatter plot graph on an excel sheet

 

also good informations about Excel and ActiveX

Excel Board

 

Hope if helps, if not please let me know.

best regards
Alexander
0 Kudos
Message 4 of 7
(3,833 Views)

For most routine things you need to do with Excel, including making graphs, the Report Object model used in recent (last 4-5 years) versions of the LabVIEW Report Generation Toolkit (which, as the previous poster noted, is included in the base version of LabVIEW 2014) is much simpler and much less prone to error than wrestling with ActiveX.

 

BS

0 Kudos
Message 5 of 7
(3,822 Views)

Hello everyone and thanks for the answers.

 

I only have the LabView Student Edition available here - is the toolkit included in it too. How can I check if it is installed/ available and in case it is installed - where can I find it?

 

Today I had time to take a look at the example


Create via ActiveX Labview a XY Scatter plot graph on an excel sheet

 



It almost does what I want in terms of creating a graph. The only problem I could not fix, is that in this example a sheet is created where only the graph is present. i'd like to add the graph to a previously created worksheet. Today I tried get this working but it seems I stilll don't really understand what I'm doing, I'll post a snippet of my code as soon as I can access the PC with LabView on it again.

 

I also took a look at the other example for inserting 2D attays - it seems to be what I need, I just had no time so far to test it, I'll post an update when I could test it.

 

Thanks for the help so far!

0 Kudos
Message 6 of 7
(3,795 Views)

Hello MrTheBrain

 

sorry, the toolkit is not included

What Features and Limitations Does the LabVIEW Student Edition Have?

best regards
Alexander
0 Kudos
Message 7 of 7
(3,767 Views)