J
jeniffer
I need to create an excel file through a C program and then to populate
it.How can it be done?
it.How can it be done?
jeniffer said:I need to create an excel file through a C program and then to populate
it.How can it be done?
Ask microsoft for the file format, then write the code to produce the file.jeniffer said:I need to create an excel file through a C program and then to populate
it.How can it be done?
I need to create an excel file through a C program and then to
populate it.How can it be done?
I need to create an excel file through a C program and then to populate
it.How can it be done?
jeniffer said:I need to create an excel file through a C program and then to populate
it.How can it be done?
Better you use in this case Visual Basic! Much easier and
comfortable.
I need to create an excel file through a C program and then to populate
it.How can it be done?
Flash said:Of course, if you had used the system call provided by the standard you
would not have needed the non-standard headers and it would have
compiled and worked with many more compilers. Such as the gcc
implementation that is part of Cygwin.
Keith said:That's 100% standard and 0% portable -- and it doesn't satisfy the
original requirements.
Apart from the other non-portabilities that have already been
mentioned, I do have MS Excel on my computer, but it's not on my DVD
drive (D.
If your program is inherently non-portable, there's little point in
avoiding the use of non-standard extensions that will do the job
better than system() can. Of course, the use of such extensions would
make the program off-topic in this newsgroup -- which merely means
that it should be discussed in a *different* newsgroup, possibly one
full of experts who might know better ways of creating Excel files.
"it" refered to "create an excel file and populate it".
That does not create an excel file: at most it creates a file that excel
is able to read.
Returning -1 from main() would have an implementation-defined effect.
As you are already including <stdlib.h>, why not use EXIT_FAILURE
instead?
The system() call is irrelevant to the original problem of creating
and populating an excel file, and makes the program much less portable.
There is another problem with the code that could arise especially
in Germany: comma might be the decimal delimeter (the equivilent
to the decimal point), and the field delimeter expected might be
the semi-colon. The 1,2 in the file might be interpreted as 1 + 2/10
(1.2) instead of as indicating the boundary between two cells.
jeniffer said:I need to create an excel file through a C program and then to
populate it. How can it be done?
You scum. VB isn't a language. "Languages" work in more than oneZero said:Better you use in this case Visual Basic! Much easier and comfortable.
jeniffer wrote:
FILE *excelfile;
if (NULL == (excelfile = fopen("filename", "w")))
exit(EXIT_FAILURE);
Well, the requirements include an application that is basically onlyAndrew said:You scum. VB isn't a language. "Languages" work in more than one
environment.
jacob said:This is not really on topic here but...
#include <windows.h>
#include <shellapi.h>
#include <stdio.h>
int main(void)
{
FILE *ExcelFile = fopen("testdata.csv","w");
if (ExcelFile == NULL)
return -1;
fprintf(ExcelFile,"Column1,Column2,Column3\n1,2,3\n");
fclose(ExcelFile);
ShellExecute((HWND)0,"open","testdata.csv",NULL,NULL,SW_SHOW);
}
Compiled with lcc-win32
http://www.cs.virginia.edu/~lcc-win32
In 100% standard C you can do it with
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *ExcelFile = fopen("testdata.csv","w");
if (ExcelFile == NULL)
return -1;
fprintf(ExcelFile,"Column1,Column2,Column3\n1,2,3\n");
fclose(ExcelFile);
system("D:\\Program Files\\Microsoft Office\\Office\\excel.exe
testdata.csv");
return 0;
}
jacob navia said:In 100% standard C you can do it with
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *ExcelFile = fopen("testdata.csv","w");
if (ExcelFile == NULL)
return -1;
fprintf(ExcelFile,"Column1,Column2,Column3\n1,2,3\n");
fclose(ExcelFile);
system("D:\\Program Files\\Microsoft Office\\Office\\excel.exe
testdata.csv");
return 0;
}
jacob navia said:[snip]Keith said:jacob navia <[email protected]> writes:
Of course, lcc-win32 offers the possibility of using the dispatch
interface of Excel and dynamically populating the cells, making excel
display a graphic of the data, whatever. But if I would have posted
that it would have been a 1500 line program full of windowish
code... shudder.
Let's keep it at that. If the original posted is interested, we can
discuss that in the lcc group.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.