Question

Is it possible to produce an Excel file in Labwindows when Microsoft Excel is not installed on the system?

I have looked at CVI samples, and although the use of Activex controls is handy in Labwindows, it presupposes that Excel is installed on the system. Is it at all possible to produce an Excel file when Excel is not installed on the system?

Was it helpful?

Solution

Yes, just create a csv file.

Excel does not have to be present on a PC to produce an Excel compatible file using LabWindows/CVI (or any one of several other C compilers.)

Without having the Excel object loaded on a PC, Here is one way to do what you ask. The caveat, in order to make the file "true Excel", it will have to be opened by Excel, on another PC, and saved in a classic Excel format (i.e. xls or xlsx)...

Here are some easy steps: (see software example below)
Create a text file with a .csv extension to start. Write records to the open file using comma delimited strings and use \n at the end of each. Once file is created, Open it in Excel using *Open as **.* (all files) to allow it to see .csv file types. Once opened, it can saved it in any Excel format you wish.

Code example (this should build with no modifications in LabWindows/CVI)

#include <windows.h>
#include <ansi_c.h>

void main(void)
{
    FILE *fp;

    fp = fopen ("C:\\tempExtract\\CsvFile.csv", "a");
    fputs("every,word,in,this,line,are,fields,in,record,one\n", fp);
    fputs("every,word,in,this,line,are,fields,in,record,two\n", fp);
    fputs("every,word,in,this,line,are,fields,in,record,three\n", fp);
    fclose(fp);


}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top