The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Excel help moe2266 UNIX for Dummies Questions & Answers 2 08-06-2007 09:20 AM
How to format excel sheets in UNIX?? Vijay06 Shell Programming and Scripting 2 05-16-2007 06:01 AM
Creating Excel Sheet in Hp-UX KVSPRASAD HP-UX 5 02-07-2007 07:16 PM
Multiple excel work sheets through UNIX puspendu Shell Programming and Scripting 1 05-03-2006 01:28 AM
excel swakoo UNIX for Dummies Questions & Answers 2 11-23-2004 09:25 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-14-2005
Registered User
 

Join Date: Dec 2005
Posts: 4
Stumble this Post!
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-14-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,808
Stumble this Post!
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
Reply With Quote
  #3 (permalink)  
Old 12-15-2005
Registered User
 

Join Date: Dec 2005
Posts: 4
Stumble this Post!
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.
Reply With Quote
  #4 (permalink)  
Old 12-15-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,808
Stumble this Post!
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.
Reply With Quote
  #5 (permalink)  
Old 12-15-2005
Registered User
 

Join Date: Dec 2005
Posts: 4
Stumble this Post!
Thank you very much for you help
Reply With Quote
  #6 (permalink)  
Old 12-19-2005
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
Stumble this Post!
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
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
  #7 (permalink)  
Old 12-20-2005
Registered User
 

Join Date: Dec 2005
Posts: 4
Stumble this Post!
Sorry, but I don't know how to write the character CTRL-PAGEDOWN.
How can I do it?
Thank you
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0