creating more than 2 excel sheets in C


 
Thread Tools Search this Thread
Top Forums Programming creating more than 2 excel sheets in C
# 1  
Old 12-14-2005
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
# 2  
Old 12-14-2005
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:

www.openoffice.org
# 3  
Old 12-15-2005
I think it works

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.
# 4  
Old 12-15-2005
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.
# 5  
Old 12-15-2005
Thank you very much for you help
# 6  
Old 12-19-2005
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
# 7  
Old 12-20-2005
Sorry, but I don't know how to write the character CTRL-PAGEDOWN.
How can I do it?
Thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Perl script to merge cells in column1 which has same strings, for all sheets in a excel workbook

Perl script to merge cells ---------- Post updated at 12:59 AM ---------- Previous update was at 12:54 AM ---------- I am using below code to read files from a dir and print to excel. open(my $in, '<', $file) or die "Could not open file: $!"; my $rowCount = 0; my $colCount = 0;... (11 Replies)
Discussion started by: Jack_Bruce
11 Replies

2. Shell Programming and Scripting

Write two csv files into one excel with multiple sheets

I have requirement to write two CSV files to one single excel with multiple sheets. Data present in the two files should sit in excel as different sheets. How can we achieve this using shell script? 1.csv 2. csv 1,2,3,4 5,6,7,8 XXXXX YYYYY Res.excel 1.csv data... (1 Reply)
Discussion started by: duplicate
1 Replies

3. Shell Programming and Scripting

create separate files from one excel file with multiple sheets

Hi, I have one requirement, create separate files (".csv") from one excel file(xlsx) with multiple sheets. These ".csv" files are my source files. So anybody please suggest me the process. Thanks in Advance. Regards, Harris (3 Replies)
Discussion started by: harris
3 Replies

4. Shell Programming and Scripting

creating excel file using perl

Hi , I am writing a simple excel file and want to create the file under say 'D:\Documents and Settings'. The problem with my code is it is writing in the same directory instead of the specified. Here is a sample code use Spreadsheet::WriteExcel; my $workbook =... (1 Reply)
Discussion started by: daptal
1 Replies

5. Shell Programming and Scripting

Sending SQL Queries output to different Excel sheets

Hi, I need your help in sedning sql queries output to different excel sheets. My requirement is like this: Query1: Select name from table1 where status = 'Complete' Query2: Select name from table1 where status = 'Failed' Query3: Select name from table1 where status = 'Ignored' ... (4 Replies)
Discussion started by: parvathi_rd
4 Replies

6. Shell Programming and Scripting

Add multiple .csv files as sheets to an excel file in unix.

Hi, I am using Solaris 8. My script outputs 4 .csv files. Currently I am SFTPing the files and creating a new excel file with the 4 files as sheets. Can anyone suggest ways to do this in UNIX ? Thanks, David. (2 Replies)
Discussion started by: libin4u2000
2 Replies

7. Shell Programming and Scripting

How to combine different Excel sheets into a single work book using UNIX

Hi All, I have 4 excel files and i want to combine these 4 files into a single workbook .. my constraints is each work sheet should go to a seperate sheet or tab with sheet name .. my final workbook should have 4 tabs(sheets) each for one. Thanks in Advance.. (3 Replies)
Discussion started by: jagadish99
3 Replies

8. Shell Programming and Scripting

How to format excel sheets in UNIX??

Hi, I have generated an excel sheet using a shell script. i have converted the output text file to an excel and got the desired output. However, in a particular column in the excel the values of the numbers start with 0. e.g. 078393343, 00342442, etc. But, in the resulting excel I get as... (2 Replies)
Discussion started by: Vijay06
2 Replies

9. HP-UX

Creating Excel Sheet in Hp-UX

Dear Members, How do I create an eqvivalant of Excel sheet in Hp-UX. Is there any application like the Microsoft Excel on HP-UX. How do I invoke it. Regards, PrasadKVS (5 Replies)
Discussion started by: KVSPRASAD
5 Replies

10. Shell Programming and Scripting

Multiple excel work sheets through UNIX

Hi, There is this requirement to create multiple work sheets in an MS Excel file through UNIX. We normally can create one work sheet in unix by either tab or comma delimiting and appending .xls or .csv to the file name, but can we create multiple work sheets. Regards, Puspendu (1 Reply)
Discussion started by: puspendu
1 Replies
Login or Register to Ask a Question