• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • 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: 43016
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic