LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Headers for output spreadsheet?

Solved!
Go to solution

Hello all. I am quite new to LabVIEW and would like to make headers for my output spreadsheet. I have made a 1D array of strings with the appropriate titles.I am having trouble getting both the data I want and the headers to appear on the output file. Another task I would like to be able to do is to be able to overwrite just the data in case I want to put in a specific set of values. For instance, I have 12 columns that will have headers, but what if I only want to show the data for only certain columns and leave the rest blank, but still have the headers show? I am not able to attach code.

 

 

Thank you.

0 Kudos
Message 1 of 8
(3,027 Views)
Solution
Accepted by topic author Szklanam

@Szklanam wrote:

Hello all. I am quite new to LabVIEW and would like to make headers for my output spreadsheet. I have made a 1D array of strings with the appropriate titles.I am having trouble getting both the data I want and the headers to appear on the output file.


If you don't show us your code how can we tell you what you're doing wrong? We are not mind readers. The typical way of doing this is to call Write to Spreadsheet File and pass it the 1D array of strings, and then call it with the data you intend to write (i.e., your 2D array). Obviously the latter will be with the "append" input set to true.

 


Another task I would like to be able to do is to be able to overwrite just the data in case I want to put in a specific set of values. For instance, I have 12 columns that will have headers, but what if I only want to show the data for only certain columns and leave the rest blank, but still have the headers show? I am not able to attach code.

This appears to be the same question you just asked: http://forums.ni.com/t5/LabVIEW/Is-there-a-way-to-select-a-certain-box-of-elements-from-a-csv/m-p/19... If it is, please keep your discussion in that thread. If it's not, please explain how it's different.

Message 2 of 8
(3,024 Views)

You can also use Report Generation toolkit to create your headers, if you have it available.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
Message 3 of 8
(3,020 Views)

I hadn't seen these solutions and figured it out myself, but yes I did exactly what smercurio_fc said. I wired my string array to the 1D array terminal of a Write to Spreadsheet, then the output of that was wired to another Write to Spreadsheet where the 2D array data was put in, then the append to file terminal was set to True. The second part of the question is different due to the fact that I want to write them instead of extract them. My thinking is that if the  only two columns I want to write are the 3rd to last and 2nd to last columns, then when they are output to the file, they will go under the first two columns instead of the desired columns. Does that clear it up at all?

0 Kudos
Message 4 of 8
(3,012 Views)

@Szklanam wrote:

 The second part of the question is different due to the fact that I want to write them instead of extract them. My thinking is that if the  only two columns I want to write are the 3rd to last and 2nd to last columns, then when they are output to the file, they will go under the first two columns instead of the desired columns. Does that clear it up at all?


You have to modify the arrayto replace the columns prior to writing it out and then write out the new, updated array. As I pointed out in your other thread, unless you have a rigid, fixed-width format for the file, you're not going to know where to write the bytes. The only thing you have available to you when writing text files is to set a file position. Open the file in Notepad. How are you going to know what the file position is where to start writing the new data?

0 Kudos
Message 5 of 8
(2,980 Views)

So if I understand this correctly, I would need to make all the other columns be filled with zeros for whatever specific array I am trying to output that way it will be zeros until the point I would like it to start at? I guess my question is better worded like this: Can labview search for the header I specify then write the data under that and have all the other columns I did not specify just be zeros/blank?

0 Kudos
Message 6 of 8
(2,962 Views)

This has nothing to do with what LabVIEW can or cannot do. You'll have the same exact problem in any programming language. It's simply a matter of the way a text file (or any file, for that matter) is stored. A text file is not stored in rows and columns. All you have is a sequence of bytes. When you open the file in Notepad or Excel it looks formatted because you have carriage return/linefeeds and tabs. However, on disk it's just one long sequence of bytes. So, if you want to replace a number in one of the columns in one of the rows, how are you going to know where to start writing? You can set a file pointer wherever you want, but you need to know exactly at which byte location the number starts, and how many characters it is. The only way this can be done is if you have fixed, known lengths for everything - numbers and headers.

0 Kudos
Message 7 of 8
(2,957 Views)

Okay. Thank you.

0 Kudos
Message 8 of 8
(2,953 Views)