creating more than 2 excel sheets in C

Hi,
I have a question about using C to write excel file.
There is a way to write into a sheet into a file excel, like this:

FILE * File;
pMyFile = fopen("test.xls", "w+");
fprintf(File, "\n\n"); /* go to the row 2 of the column A*/
fprintf(File, "%s", "Hi pippo!"); /* write the string "Hi pippo"*/

The question is:
Is there something like this that allow me to write in a second sheet, in the same xls file?
Otherwise is there a package in C or something like that to manipulate excel file?
Thank you

  1. the code you show won't compile
  2. fprintf(FIle,"\n\n") places two line feeds in the file, that does'nt mean it went to line #2
  3. OpenOffice or old Star Office have routines that can manipluate .XLS files.

See:

I've inserted "\n\n" in an example and the result is to go two line below.
Maybe there is a misunderstanding, I did't tell you that I'm using Microsoft Excel to open the files generated by C code.

What you seem to be creating is called a comma-delimited (.csv) file. It can also be tab-delimited In order to have multiple worksheets or workbooks you need a format called BIFF - specifcally BIFF2 or BIFF4.

If you don't like my answer then goto www.wotsit.org --
and look up the file structure for xls files.

Open the pdf file on the XP version. It is very large because the format of these files is not trivial. You will find a format called BIFF2 and BIFF4. The records you are writing are not in that format. These formats store separate worksheets/workbooks.

And it makes no sense to create a file with worksheets unless it will be opened by OpenOffice or by Micrsoft Excel. There is nothing else I can contribute.

Thank you very much for you help

hmm, may be what jim says is right. However I have a suggestion, not sure if it works.
As per your logic, I understand you are actually just sending a stream of characters to a file, and that when opened by an xls files is interpreted as per its own format and hence the 2 new line characters mapped to 2 cell below. Thinking on the same lines, why dont you try streaming the "ctrl-pagedown" character (next sheet in excel) and then some printable characters that will write to this next sheet.
Now the difficult part is to identify the ctrl-pagedown character (or characters rather) with some luck you can get those non-printable characters, write them to this file and then see if it works. My guess is it should.
let me know

Sorry, but I don't know how to write the character CTRL-PAGEDOWN.
How can I do it?
Thank you

CTRL-PAGEDOWN will have some ascii value, it may be one character or a set of characters. let say this value is 26, then you can fprintf(File,"%c",26);