LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write To Excel -> Let Excel Make Math -> Get the Result with Read

Hi,

 

I made a really simple program in Labview that right data in an Excel Chart, and a second part where i can read the data from an excel chart.

 

The problem right now is that i want Excel to make the thermodynamic calculation(already program for that), but i cannot understand why I cant put data(always at the same place and don<t need to be save) in this spreadsheet with Labview, make the calculation with Excel and then take the value of table (my Q) and put it back in Labview.

 

Any Help would be appreciated,

 

Thank You


S/bastien Goffi 

 

P. S: The program I wrote is done by a noob, don<t mind the number of loop, and the programmation that is in interrested right now is the top right one in the second sequence of the main program.

0 Kudos
Message 1 of 8
(3,415 Views)

Sorry, I'm "on the road" and brought the laptop with LabVIEW 2012, but not 2013, installed, hence I can't look at your code.

 

Are you using the Microsoft Office Report Toolkit to read and write into an Excel Workbook?  You mention an "Excel Chart" -- did you mean an Excel Chart Object, a graphic "image" of Excel data?

 

If you are using the Report Toolkit and open an Excel Report, you should be able to write data into cells on an Excel Spreadsheet.  You should also be able to write formulas (or use a pre-written Workbook with the formulas already written to the Spreadsheet) to do whatever calculations you need.

 

To keep things "neat and clean" (and make it easier to debug), I'd recommend doing the following:

 

In Column A, write the data points you want to use in the computation, using multiple rows, if necessary.

In Column B, write the formulas you need to transform the "input data" in Column A into "Results".

 

For example, suppose you want the squares of the numbers you supply (I realize this is a trivial example, but it illustrates the point).  Let's say you have 10 values.

 

In Column A, rows 1 through 10, you'd write the 10 data values.

In Column B, rows 1 through 10, you'd either write the formula "=A1*A1" (changing "A1" to "A2", "A3", ... "A10" for successive entries) or you would use a file where the formulas were already written.

 

When you open the Workbook in Excel and write the data intol Column A (and B, if necessary), you should be able to read out the Results from Column B.  Note that if your original Workbook already had the formulas "in place" and you don't save the Workbook after entering the data, the formulas will still be present and the Workbook can be "reused" for new data.

 

Bob Schor 

 

0 Kudos
Message 2 of 8
(3,405 Views)

Thank You for your answer,

 

I am using atm Write to SpreadSheet File and Read to SpreadSheet File, I already tried what you said ( in the first attempt) but it seem like, i cannot write data in the already pre-program Excel chart with function in it, if you want, i can add the excel chart I am talking about to a message ?

 

Thank You,

 

Sebastien Goffi 

0 Kudos
Message 3 of 8
(3,374 Views)
Write to Spreadsheet and Read from the Spreadsheet do not write/read native Excel files. They are for tab or comma separated text files. You must use ActiveX functions such as are in the Report Generation Toolkit or in the numerous examples on the board.
0 Kudos
Message 4 of 8
(3,360 Views)

The write to spreadsheet work pretty fine... It create a excel chart and put value in each case, the goal now is to let excel do the math(already program to do it) and i want Labview to check those new value and display it. 

 

The only problem now is when i start to do that, Labview make a new excel chart and then don't read the value is suppose to read. 

 

Thank You,

 

I am gonna investigate on the Report Generation Toolkit, could you link one of your numereous examples you are talking about ?

 

Sebastien Goffi 

0 Kudos
Message 5 of 8
(3,355 Views)

If i take example on http://www.ni.com/example/28409/en/ that kind of VI, it open Excel each time, so it's not really what I want because I am already working on excel for other thing too. 

0 Kudos
Message 6 of 8
(3,339 Views)

I think the obvious question here is:  Why do you "... want Excel to make the thermodynamic calculation"?  It sounds like you are going through a LOT of effort to use Excel to do a calculation that should be done in program anyway. Making LV process the data will likely be far faster than having Excel do it.  Excel is also limited in the size / dimensions of the data it can process.

 

Unrelated, why on earth do you have a while loop with a bunch of while loops inside of it?  I can not think of a single case in which this makes sense.   You would do yourself a big favor by looking at some basic labview coding techniques.  If nothing else, at least glance over this:

 

http://www.ieee.li/pdf/viewgraphs/labview_design_patterns.pdf

0 Kudos
Message 7 of 8
(3,328 Views)

With luck, this is a link to a post I made in January to provide a revised Generate Excel Report example.  If the link doesn't work, you should be able to find it knowing the title ...

 

http://forums.ni.com/t5/LabVIEW/Revised-quot-Generate-Excel-Report-quot-Example/m-p/2699093#M801671

 

The key point is that the Report Generation Toolkit actually runs Excel, so that the Excel "engine" is available for doing computations or formula manipulations (like the math you want to do).  Using the LabVIEW Read/Write Spreadsheet does not call Excel -- rather it writes a text file that Excel can subsequently read.  So you could use LabVIEW to write your data into an Excel-readable "spreadsheet", close LabVIEW, open Excel, create the formula you want, have Excel do it, save the Spreadsheet, close Excel, go back to LabVIEW, do a "Read from Spreadsheet", and finish your program, but that's clearly not what you want to do.

 

Using the Report Generation Toolkit, you use LabVIEW to gather the data, directly open and write an Excel "Report", complete with the formulas you want to use to do the calculations in Excel, then (while the Report is still open) read the results back into LabVIEW and (optionally) save and close the Report.

 

If you do not have access to the Report Generation Toolkit, then this approach is not possible.  If you do have the Toolkit available, install it and try it out (modify my example to suit your needs).  If you are still "stuck", create a small Excel spreadsheet (complete with the formulas you want to use) and post it so I can get a better idea of what you are trying to accomplish.

 

Bob Schor

0 Kudos
Message 8 of 8
(3,325 Views)