作者:乔山办公网日期:
返回目录:excel表格制作
1、使用VS新建空工程,直接点击确定,如下所e799bee5baa6e79fa5e98193e78988e69d83335示。
2、新建c文件,用于C语言编译器,输入main.c文件,如下所示。
3、参考代码:
#include <stdio.h>
int main()
{
//下面是写数据,将数字0~9写入到data.txt文件中
FILE *fpWrite=fopen("data.txt","w");
if(fpWrite==NULL)
{
return 0;
}
for(int i=0;i<10;i++)
fprintf(fpWrite,"%d ",i);
fclose(fpWrite);
//下面是读数据,将读到的数据存到数组a[10]中,并且打印到控制台上
int a[10]={0};
FILE *fpRead=fopen("data.txt","r");
if(fpRead==NULL)
{
return 0;
}
for(int i=0;i<10;i++)
{
fscanf(fpRead,"%d ",&a[i]);
printf("%d ",a[i]);
}
getchar();//等待
return 1;
}
4、编译完成后,运行exe程序,执行后显示console程序。
Dim excel As Object
Set excel = CreateObject("excel.application") '设定 excel API
'--------------这上面可百不看度 照抄
excel.workbooks.Open ("C:\book.xls") 'P.s请先自问己创立答 'excel 开启
excel.Visible = True 'excel 显示 or 隐藏专 (True of False
excel.cells(1,2)="测试"
text1 = excel.cells(1,2) 'text1 读取
excel.ActiveWorkbook.Save 'excel 存档属
excel.quit 'excel 关闭