LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Writing Table and Graph to Excel

I am using a slightly modified version of the shipping example 'Write Table and Chart to XL' within my application. The problem I am having is that I would like to be able to input x values (right now the default is incrementing by one for each 'y' value read to excel). For instance I would like column B, cell values 2 to 110, to be my x, with columns D, E, and F, cells 2 to 110 to be my respective y values. I am having a little trouble figuring out how to accomplish this.

Also, I would like to be able to choose the type of plot within Excel. For instance, whether or not the points are connected, and the scales on the X and Y axis.

Then, how would I automatically assign a file name, and save this Excel Work
book.

I am attaching my vi for reference, just it case it helps.

Any help provided would be greatly appreciated.

Thanks
0 Kudos
Message 1 of 7
(3,752 Views)
Looks like you are 98% there. The chart options you are looking for are already included in your code. To get an XY chart set the front panel Chart Wizard->Chart Type to XYScatterLines (connected) or XYScatter (not connected). The scale labels are also wired.

If you need to adjust the scales, you will need to wire the output of the ChartWizard into:
Method Axes
convert to Axes
Method Item(xlValue)
Property MaximumScale (or another property)

The assign a file name, duplicate the Close Spreadsheet case and change the Method Close to Method Save As.

Michael
www.abcdefirm.com
www.stitchofclass.com
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
Message 2 of 7
(3,752 Views)
Michael,

Thanks for the help. So far so good.

I understand what you are trying to get me to do to adjust the scales, but I can't find the referenced items that you suggest wiring the output of the chart Wizard to. Do I need to type these into the unbundle by name within the chardwizard vi, or what. Sorry it this seems like a stupid question, but I am still pretty new to LabVIEW.

I also changed the method to 'Save As' and when I went to assign a file name, I created a constant, and I tried typing and nothing happened, I still just had a flashing cursor. Any idea what I am doing wrong.

Thanks a ton,
Travis
0 Kudos
Message 3 of 7
(3,752 Views)
Hi Travis,

You can find the Property Node and Method Node on the Functions Pallette under Application Control. Right click on the Properties to select the function after you wire the Chart into the reference input. Cascade the property ouput into the reference input of the next node. Be sure to use the Automation Close on every reference that does not leave the page.

You will also need another front panel refnum by selecting ActiveX->Automation Refnum and browse for Excel.Axes. This wires into the top input of Variant to Data to convert the Axes Variant into an Axes reference. From there a Property Node shows all of the relevant options.

For the Save As file name, you cannot use a variant constant. Instead, manually drop a
string control onto the front panel and wire it directly into the Filename input. Excel will convert it for you.

Michael
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 4 of 7
(3,752 Views)
Michael,

So far your help has been awesome. I have accomlished a lot of other tasks on my 'to do' list. I still have a few questions about the chart axis -- I have been able to find and work with most of what you have referenced, and I have found where I would have to select xlValue, but I am unable to choose this option. Also, once I have completed this, how will I set it up so that I can enter a cell range for what I would like my x-axis values to be, such I did with the 'y'.

Thanks a ton,
Travis
0 Kudos
Message 5 of 7
(3,752 Views)
Travis,

If you selected xlScatterLines as the chart type, the ChartWizard should automatically use the first column as your X values for all other columns. It may be that your data has the X values in the "A" column and you are not passing that column to the ChartWizard.

If you need to create a standard line chart and then convert it to an XY chart later, set each of the Chart.SeriesCollection(n).XValues to the worksheet range.

Use Worksheet Method Range to specify the block of X Values
Chart Invoke Node->SeriesCollection
Start Index input at 1
Convert SeriesCollection Variant to Type Excel.Series
Series Property Node->XValues
Change to Write
Wire in the range above
Loop thru each SeriesCollection


Michael
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 6 of 7
(3,752 Views)
Michael,

Can you explain what you mean when you said "Loop through each Series Collection? I have included what I thought you meant in my program, but my program doesn't work. Thanks. Also, what if you need to graph different series as C2 to C27, C28 to C54, etc....

Analog
0 Kudos
Message 7 of 7
(3,752 Views)