Summary: In this lesson, you will learn how to format text files for use in spreadsheets.
To write data to a spreadsheet file, you must format the string as a spreadsheet string, which is a string that includes delimiters, such as tabs. In many spreadsheet applications, the tab character separates columns, and the end of line character separates rows.
Functions>>All
Functions>>String palette to ensure portability of VIs
among platforms. (Windows) The constant
inserts a carriage return and a linefeed. (Mac
OS) The constant inserts a carriage
return. (UNIX) The constant inserts a
linefeed.
Use the Write To Spreadsheet File VI or the
Array To Spreadsheet String function to convert a
set of numbers from a graph, a chart, or an acquisition into a
spreadsheet string. If you want to write numbers and text to a
spreadsheet or word processing application, use the String
functions and the Array functions to format the data and to
combine the strings. Then write the data to a file.
Use the Format Into File function to format
string, numeric, path, and Boolean data as text and write the
text to a file. Often you can use this function instead of
separately formatting the string with the Format Into
String function or Build Text Express VI
and writing the resulting string with the Write
Characters To File VI or Write File
function.
Use the Format Into File function to determine
the order in which the data appears in the text file. However,
you cannot use this function to append data to a file or
overwrite existing data in a file. For these operations, use
the Format Into String function with the
Write File function. You can wire a
refnum or path to the input
file terminal of the Format Into File
function, or you can leave this input unwired for a dialog box
to prompt you for the filename.
In the block diagram shown in Figure 1, the
Open/Create/Replace File VI opens a file, and the
For Loop executes five times. The Format
Into File function converts the iteration count and the
random number to strings and places the tab and end of line
characters in the correct positions to create two columns and
one row in spreadsheet format. After the loop completes five
iterations, the file closes, and the VI checks the error
condition.
![]() |
This VI creates this text file, where an arrow (→) indicates a tab, and a paragraph symbol (¶) indicates an end of line character.
0→ 0.798141¶
1→ 0.659364¶
2→ 0.581409¶
3→ 0.526433¶
4→ 0.171062¶
You can open the previous text file in a spreadsheet application to display the spreadsheet shown in Figure 2.
![]() |
In the block diagram shown in Figure 3, the
Write LabVIEW Measurement File Express VI
includes the open, write, close, and error handling
functions. It also handles formatting the string with either a
tab or comma delimiter. The Merge Signals
function combines the iteration count and the random number
into the dynamic data type.
![]() |
The dialog box in Figure 4 shows the
configuration for the Write LabVIEW Measurement File
Express VI.
![]() |
This VI creates a .lvm file which you can open in
a spreadsheet application. Figure 5 shows an
example of the spreadsheet created by the previous
configuration of the Write LabVIEW Measurement File
Express VI.
![]() |
Refer to the lesson on Data Acquisition and
Waveforms, for more information about the Write
LabVIEW Measurement File and Read LabVIEW
Measurement File Express VIs.
"A full introductory course on programming with LabVIEW."