c++builder StringGrid导入数据到Excel
大家好,小弟最近碰到个问题一直不能解决,还请大家多多帮忙
这是程序
Variant ExcelApp,Workbook,Sheet;
ExcelApp=Variant::CreateObject("Excel.Application");//创建Excel应用程序对象
ExcelApp.OlePropertySet("Visible",true); //设置应用程序显示
ExcelApp.OlePropertyGet("Workbooks").OleProcedure("Add");//创建工作薄对象相当于子MDI
Workbook=ExcelApp.OlePropertyGet("ActiveWorkbook"); //获取当前工作薄
Sheet=Workbook.OlePropertyGet("ActiveSheet"); //获取当前工作表
Variant Range;//设置操作范围
for(int j=0;j<SG->ColCount;j++) //选取每一列
for(int i=0;i<SG->RowCount;i++) //选取每一行
{
AnsiString StrValue=StringGridA->Cells[j][i];
Sheet.OlePropertyGet("Cells",i+4,j).OlePropertySet("Item",StrValue.c_str());
}
}
看到网上大家基本都是这么做的,可我一直出现问题
如下
raised exception class EOleSysError with message '发生意外。'
不知道问题在哪里呀????
这是程序
Variant ExcelApp,Workbook,Sheet;
ExcelApp=Variant::CreateObject("Excel.Application");//创建Excel应用程序对象
ExcelApp.OlePropertySet("Visible",true); //设置应用程序显示
ExcelApp.OlePropertyGet("Workbooks").OleProcedure("Add");//创建工作薄对象相当于子MDI
Workbook=ExcelApp.OlePropertyGet("ActiveWorkbook"); //获取当前工作薄
Sheet=Workbook.OlePropertyGet("ActiveSheet"); //获取当前工作表
Variant Range;//设置操作范围
for(int j=0;j<SG->ColCount;j++) //选取每一列
for(int i=0;i<SG->RowCount;i++) //选取每一行
{
AnsiString StrValue=StringGridA->Cells[j][i];
Sheet.OlePropertyGet("Cells",i+4,j).OlePropertySet("Item",StrValue.c_str());
}
}
看到网上大家基本都是这么做的,可我一直出现问题
如下
raised exception class EOleSysError with message '发生意外。'
不知道问题在哪里呀????
...全文
相关推荐
ImpStringGrid (增强StringGrid控件)
ImpStringGrid (增强StringGrid控件) ImpStringGrid (增强StringGrid控件)
StringGrid导出到EXcel
使用C++ builder6,StringGrid导出到EXcel,导出新的excel文件或者模板。两个程序的代码在文档中
C++不用OLE将StringGrid数据转换为Excel的实例.rar
C++不用OLE将StringGrid数据转换为Excel的实例.rar
c++builder中使用advstringgrid导出数据到excel
c++builder advstringgrid导出数据 excel c++builder中使用advstringgrid导出数据到excel
RS232至excel数据保存
将RS232的数据保存至excel 动态变化


