NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
bobholmgren
Posts: 116
0 Kudos

Switch Excel columns and rows in write to spreadsheet and more

I'm trying to get the output from a machine, output it to a spreadsheet, and potentially have it graph the data in Excel.

My code and the resulting spreadsheet are attached.

 

I want the data to be vertical, with all the data being in Columns A and B as opposed to being in Rows 1 and 2

i also want to add Column titles for Voltage and Current.

If possible, I would also like to be able to graph the data automatically.

 

I am running Labview 7.1.

Thank you

Trusted Enthusiast
Darin.K
Posts: 3,939

Re: Switch Excel columns and rows in write to spreadsheet and more

Play with the Transpose Input of the Write To Spreadsheet File VI.

Member
bobholmgren
Posts: 116
0 Kudos

Re: Switch Excel columns and rows in write to spreadsheet and more

Thanks, that switched my rows/columns. 

 

Now I just have to add the column titles and see if its possible to automatically graph the data. 

Any suggestions?

Trusted Enthusiast
Darin.K
Posts: 3,939

Re: Switch Excel columns and rows in write to spreadsheet and more

Use Write Characters to File to write your column labels.  Wire the Path Out from that VI to the Write Spreadsheet file and set Append to true.

 

As for Graphing, someone who actually uses Excel would have to help there.  I would check out the examples or check out this thread for Excel questions (NO POSTING, JUST READING).

 

http://forums.ni.com/t5/BreakPoint/Excel-Board/m-p/379682

 

 

Knight of NI
Posts: 18,064

Re: Switch Excel columns and rows in write to spreadsheet and more

If you were running a newer version of LabVIEW I'd say the following: just call the Write to Spreadsheet File and pass it a 1D array of strings that are your column headers. When writing the actual data with the 2D array make sure you have the "append" set to true.

 

Since you're running LabVIEW 7.1, the Write to Spreadsheet File VI is not polymorphic. So, you have 2 choices:

  1. Make a version that accepts strings. If you open the Write to Spreadsheet File VI and look at the block diagram it contains instructions on how to make a version that accepts a different datatype. Make sure you save this new VI with your files, and not in the LabVIEW vi.lib directory.
  2. Use the standard File I/O functions to write out your columns to the file prior to using the Write to Spreadsheet File VI.

 


If possible, I would also like to be able to graph the data automatically.


Your images shows a graph terminal, so I don't understand this question.

 

Member
bobholmgren
Posts: 116
0 Kudos

Re: Switch Excel columns and rows in write to spreadsheet and more

This post seems like it would have been helpful, but the code is for Labview 2009, and I only have Labview 7.1

http://forums.ni.com/t5/LabVIEW/Running-a-Excel-macro-from-a-open-workbook/m-p/1023514?jump=true

 

 

I have written a macro for Excel to draw the graph, I just have to be able to have Labview run it after it outputs the data.

I want to output an excel file with all the data and a graph of the data in it.

 

 

 

 

Member
bobholmgren
Posts: 116
0 Kudos

Re: Switch Excel columns and rows in write to spreadsheet and more

Oh, and if possible, I'd like Labview to store the macro (not the xls file) so that this is more platform independent, and the user doesn't have to deal with installing the macro

Knight of NI
Posts: 18,064

Re: Switch Excel columns and rows in write to spreadsheet and more

If you need to work with actual Excel workbooks, then you can't use Write to Spreadsheet File. That creates text files, not Excel workbooks. Excel workbooks are a proprietary format, and you need to use ActiveX to manipulate Excel. There are examples that ship with LabVIEW on how to use ActiveX, including a couple of examples on using it to control Excel. Open the Example Finder (Help -> Find Examples) and search for Excel. Also, as Darin indicated, look at the many links in the Excel thread that point to other examples. As noted, do not post question in that thread.

Member
bobholmgren
Posts: 116
0 Kudos

Re: Switch Excel columns and rows in write to spreadsheet and more

[ Edited ]

Thanks, I thought I was hitting a roadblock like that after I ran a macro on a text file I'd renamed as .xls and it asked me to resave in excel format.

I'll try looking through some of the examples and come back here if I need more help.

 

Thanks again

Member
bobholmgren
Posts: 116
0 Kudos

Re: Switch Excel columns and rows in write to spreadsheet and more

Alright, I'm having major issues trying to figure out the activex stuff to get it working. Does anyone know of a good activex/labview tutorial? An excel specific one would be amazing.