读书人

Excel 导入解决办法

发布时间: 2012-02-07 17:45:37 作者: rapoo

Excel 导入
导入程序:把一张具有多个sheet页的Excel表中单元格的内容赋值给软件中已经定义好的参数?

[解决办法]

C/C++ code
void __fastcall TForm1::Button2Click(TObject *Sender){    #define     PG     OlePropertyGet    #define     PS     OlePropertySet    #define     FN     OleFunction    #define     PR     OleProcedure    Variant   Ex,Wb,Sh1;    Ex=Variant::CreateObject( "Excel.Application");    Ex.PG("WorkBooks").PR( "Open","d:\\book1.xls");    Wb=Ex.PG( "ActiveWorkBook");   Sh1=Wb.PG( "ActiveSheet");    Edit1->Text=Sh1.PG( "Cells",1,1).PG( "Value");    //读出来    for   (int   i=1;i <=10;i++)        for   (int   j=1;j <=10;j++)            Sh1.PG( "Cells",i,j).PS( "Value",i*100+j); //写进去    Wb.PR( "Save");   Wb.PR( "Close");}
[解决办法]
对,就是那样操作的,但好像对2007不起作用

读书人网 >C++ Builder

热点推荐