|
void __fastcall TMicrophoneConfigForm::bsSkinButton4Click(TObject *Sender)
{
AnsiString FileName;
if(bsSkinOpenDialog1->Execute())
{
FileName = bsSkinOpenDialog1->FileName;
}
Variant ex=Variant::CreateObject("Excel.Application");
ex.OlePropertyGet("WorkBooks").OleProcedure("Open", FileName);
Variant awb=ex.OlePropertyGet("ActiveWorkBook");
//Variant sh=awb.OlePropertyGet("ActiveSheet");//엑티브sheet
Variant sh=awb.OlePropertyGet("Sheets").OlePropertyGet("item",1);//sheet1
//Variant sh=awb.OlePropertyGet("Sheets").OlePropertyGet("item",2);//sheet2
int row=sh.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count"); //row갯수
int col=sh.OlePropertyGet("UsedRange").OlePropertyGet("Columns").OlePropertyGet("Count");//col갯수
bsSkinStringGrid1->RowCount=row+1;
bsSkinStringGrid1->ColCount=col+1;
for(int i=0;i<col;i++)
{
bsSkinStringGrid1->Cells[3][i+1]=sh.OlePropertyGet("Cells",1,i+1).OlePropertyGet("Value");
}
awb.OleProcedure("Close");
ex.OleProcedure("Quit");
awb=Unassigned;
ex=Unassigned;
}
이 같이 했는데 오픈해서 excel파일 선택하고 확인 누르면 Access violation at addess 005D4AA3 in module 's~.exe', Read of address 00000800. 이런 오류가 납니다. 해결해 주세요 제발~~ 컴포넌트는 OpenDialog밖에 안썻거든요 다른 컴포넌트가 안들어가서 그런건 아닌지...
|