How to export data to Excel tabular form by "fprintf&qu

Status
Not open for further replies.

chihhao

Full Member level 4
Joined
Apr 4, 2004
Messages
204
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,298
Activity points
1,701
Hi
I would like to export some number to excel file but it always be
placed at location A1 without placing at A2,A3,.... in order.
Would someone please kindly advise me how to do it ?
Thanks!!!!

=================================
#include <stdio.h>
void main()
{
int index;
FILE *fptr;
fptr=fopen("c:\\temp\\C_Practice\\test.xls","a");
for(index=0;index<=100;index++)
{
fprintf(fptr,"%3d",index);
}
fclose(fptr);
}
=================================
 

Re: How to export data to Excel tabular form by "fprint


You need to delimit the data with comma's. (Tabs would work also)

Anyways if you change the printf to "%3d," that would give you what you want. with an empty column at end or you can add some extra checks to avoid the last column.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…