怎样样将StringGrid 控件内的数据保存到*.txt,*.xls中

liujl9754 2002-03-22 10:19:38
保存到*.txt文件,但是怎么保存为*.xls文件.我是了很多方法还是不行,帮忙一下.
...全文
104 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
40Star 2002-03-22
  • 打赏
  • 举报
回复
StringGrid1->Rows->SaveToFile
kingcaiyao 2002-03-22
  • 打赏
  • 举报
回复
please see the following code:
//define in header file
#define OlePropertySet PS
#define OlePropertyGet PG
#define OleFunction FN
#define OleProcedure PR
.cpp File
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Variant V,WB1,SH1;
V=Variant::CreateObject("Excel.Application");
V.PS("Visible",true);
V.PG("WorkBooks").PR("Open","c:\\Chenbin\\BCB\\Excel\\Book1.xls");
WB1=V.PG("ActiveWorkBook");
SH1=WB1.PG("ActiveSheet");
CCEdit1->Text=SH1.PG("Cells",1,1).PG("Value");
for(int i=1;i<=RowCount;i++)
{
for(int j=1;j<=ColCount;j++)
{SH.PG("Cells",i,j).PS("Value",StringGrid->Cells[i-1][j-1]);
}
}
V.PR("Save");
//V.FN("Close");
V.PR("Quit");
V=Unassigned;
WB1=Unassigned;
SH1=Unassigned;
ShowMessage("The Excel application has been opened by BCB");
}

552

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 茶馆
社区管理员
  • 茶馆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧