StringGrid导入Excel中出现问题
TStringGrid*sgrid;
int ii,jj,pp;
int CC;
AnsiString ass,assn;
Variant my_excel;
Variant all_workbooks;
Variant my_workbook;
Variant my_worksheet;
Variant my_range;
//
PropertyGet Range("Range");
PropertySet SetValue("Value");
sgrid=StringGrid3;
my_excel=CreateOleObject("excel.application");
my_excel.OlePropertySet("Visible",true);
all_workbooks=my_excel.OlePropertyGet("Workbooks");
my_workbook=all_workbooks.OleFunction("Add");
//获取激活的Sheet
my_worksheet=my_excel.OlePropertyGet("ActiveSheet");
//输出一个标题
my_range=my_worksheet.Exec(Range<<"A1");
my_range.Exec(SetValue<<"输出自己的表");
Range.ClearArgs();
SetValue.ClearArgs();
CC='A';
pp=2;
for(jj=0;jj<sgrid->RowCount;jj++)
{
for(ii=0;ii<sgrid->ColCount;ii++)
{
assn=char(CC+ii);
assn=assn+IntToStr(pp);
ass="";
ass=sgrid->Cells[ii][jj];
my_range=my_worksheet.Exec(Range<<assn);
my_range.Exec(SetValue<<ass);
Range.ClearArgs();
SetValue.ClearArgs();
}
pp++;
}
my_range.Exec(SetValue<<ass);程序运行到这时出现问题
Project Similar2.exe raised exception class EOleException with message 'OLE error 800AC472'. Process stopped. Use Step or Run to continue.