Go Back   The UNIX and Linux Forums > Top Forums > Programming
.
google site



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-14-2005
Registered User
 

Join Date: Dec 2005
Posts: 4
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
Sponsored Links
  #2 (permalink)  
Old 12-14-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,156
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 (permalink)  
Old 12-15-2005
Registered User
 

Join Date: Dec 2005
Posts: 4
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 (permalink)  
Old 12-15-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,156
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 (permalink)  
Old 12-15-2005
Registered User
 

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

Join Date: May 2002
Location: India
Posts: 326
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 (permalink)  
Old 12-20-2005
Registered User
 

Join Date: Dec 2005
Posts: 4
Sorry, but I don't know how to write the character CTRL-PAGEDOWN.
How can I do it?
Thank you
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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 01:20 PM
How to format excel sheets in UNIX?? Vijay06 Shell Programming and Scripting 2 05-16-2007 10:01 AM
Creating Excel Sheet in Hp-UX KVSPRASAD HP-UX 5 02-07-2007 11:16 PM
Multiple excel work sheets through UNIX puspendu Shell Programming and Scripting 1 05-03-2006 05:28 AM
excel swakoo UNIX for Dummies Questions & Answers 2 11-24-2004 01:25 AM



All times are GMT -4. The time now is 09:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0