学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
 13 12
发新话题
打印

大虾们,能给个把VC运行结果直接输出到excel中的程序吗?急求

大虾们,能给个把VC运行结果直接输出到excel中的程序吗?急求

如题,谢谢各位啦。

TOP

用,号隔开尝试下,然后xls做文件扩展名
学习需要安静。。海盗要重新来过。。

TOP

回复 2# 的帖子

是应该这样子么?

#include<stdlib.h>
#include<iomanip.h>
#include<math.h>
#include<stdio.h>
main()
{FILE *fp1,*fp2;
int i;
float wh[4];
fp1=fopen("E:\\wenjianduru\\wh.txt","rb");
if(fp1==NULL)
{printf("cannot open this file\n");
exit(0);}
for(i=0;i<4;i++)
fscanf(fp1,"%f",&wh[i]);
fclose(fp1);
for(i=0;i<4;i++)
printf("%f ",wh[i]);
fp2=fopen("E:\\wenjianduru\\wh2.xls","wb");
if(fp2==NULL)
{printf("cannot open this file\n");
exit(0);}
for(i=0;i<4;i++)
fscanf(fp2,"%f,",wh[i]);
fclose(fp2);
getchar();
}

TOP

顶。。。。。。。。。。。。

TOP

回复 4# 的帖子

可是只能生成一个空的表格,没有结果输出来啊?而且即使改成txt格式,也只是生成一个空文档。哪错了呢?

TOP

说错了是\t

fprintf(fp2,"%d\t",i);
学习需要安静。。海盗要重新来过。。

TOP

回复 6# 的帖子

貌似不是那个的问题,你能不能帮看下,其实什么都没输出来。不管让他以何种格式输出?谢啦,对C 我太菜了

TOP

首先是fprintf(fp2,"%d\t",i); 后面你在看看你读取文件的方式;最后是用\t,和扩展名字的问题
学习需要安静。。海盗要重新来过。。

TOP

回复 8# 的帖子

不行,还是不行 你能不能给个小程序哈?我觉得我这个离正确还遥遥无期

TOP

#include<stdlib.h>
#include<iomanip.h>
#include<math.h>
#include<stdio.h>
int main()
{
    FILE *fp2;
    int i;
    fp2=fopen("wh2.xls","wb");
    if(fp2==NULL)
    {
        printf("2.cannot open this file\n");
        exit(0);
    }
    for(i=0;i<100;i++)
    fprintf(fp2,"%d\t",i);
    fclose(fp2);
    getchar();
    return 0;
}
学习需要安静。。海盗要重新来过。。

TOP

 13 12
发新话题