Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to use excel file in C program for file handeling?

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to use excel file in C program to store data & retriving of data.
I can read & write word file. How to read from and write into excel file?

I am sending code for word files.

#include<stdio.h>

struct Employee{
char code[4];
char delim;
char name[10];
};


void main()
{
struct Employee e,e1;
FILE *fp;
printf("Enter the code:");
scanf("%s",e.code);
printf("Enter the name:");
scanf("%s",e.name);
e.delim='\t';
fp=fopen("new.doc","w");

fwrite(&e,sizeof(struct Employee),1,fp);
printf("\n");
fclose(fp);

fp=fopen("new.doc","r");
while(fread(&e1,sizeof(struct Employee),1,fp))
{
printf("%s",e1.code);
if(e1.delim=='\t')
printf(":");
printf("%s",e1.name);

}
printf("\n");
}
 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does that code really create a file Word can open? DOC and XLS have very complex file formats, which this code seems to ignore entirely.

Since you posted this on a Java discussion site, are you interested in somehow using Java to solve this? If so, you can use JNI to embed a JVM in your C code, and then use one of the Java libraries mentioned here to interact with the file.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic