LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

titles for spreadsheet-files

Hallo,

I have to write a 2D-array to a text-file and I want to give each column a title, f.e:

a b c
1 2 3

Possibly the columns in diferent files I have to write have a different width, f.e. one tab, two tabs, three tabs. Than the titleline should have the same width.

How can I do that? Possibly with "format into string", but that didn't work a I wanted. And filling up the titlename with spaces " " is much to complicated.

Arno
0 Kudos
Message 1 of 5
(2,863 Views)
If you are using Write To Spreadsheet File for the 2D data, all you have to do is first use Write Characters to File with a tab separating the column names and a line feed at the end. Pass the file name from there to the Write to Spreadsheet and set that to append to file. I've attached a picture describing what I mean and the text input to write characters has '\' Code Display turned on to show the control characters.
0 Kudos
Message 2 of 5
(2,863 Views)
Hi Dennis,

thanks for your answer. My problem stays the same if you look at the attached VI with export-file. I need the precision and the scientific notation. Adding more tabs would help, but not anymore with shorter numbers. I prefer a "general" solution for both cases.

Arno
Download All
0 Kudos
Message 3 of 5
(2,863 Views)
I wasn't aware that you were trying to read the file in anything other than Excel. That would be one general solution. Let Excel line things up for you.
0 Kudos
Message 4 of 5
(2,863 Views)
Arno

There are really two different solution to the problem, and they are not compatible.

(1) If you want to write the file so it can easily be read again by a computer or a higher level application (e.g. excel), you need to be strict with tabs and spaces. Inserting extra tabs and spaces will only mess things up.

(2) If you want to dress up your table for purely human visual inspection, it is a different problem. In this case, you should stay away from tabs entirely, because you'll never know how the tabs are set, or if tabs are even supported (such as in a LabVIEW string indicator). You also need to assure that the display is set to a fixed-width font (e.g. Courier). In a proportional font, it will be very hard to line up things because every c
haracter has a different width.

"Filling up the title name with spaces" is simple, just format the short string e.g. with "%15s" and it will magically be padded on the left.

I have attached one possible solution, it probably could be simplified quite a bit. Currently, the fields are right-aligned. Notice that the display is set to Courier, a fixed font.

Another solution would be to generate an HTML table by inserting the proper tags, then display it in a browser.
0 Kudos
Message 5 of 5
(2,863 Views)