|
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Variant ex=Variant::CreateObject("Excel.Application");
ex.OlePropertyGet("WorkBooks").OleProcedure("Open","c:\\리스트1.xls");
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갯수
StringGrid1->RowCount=row+1;
StringGrid1->ColCount=col+1;
for(int j=0;j<row;j++){
for(int i=0;i<col;i++){
StringGrid1->Cells[i+1][j+1]=sh.OlePropertyGet("Cells",j+1,i+1).OlePropertyGet("Value");
}
}
awb.OleProcedure("Close");
ex.OleProcedure("Quit");
awb=Unassigned;
ex=Unassigned;
}
위와 같은 경우 StringGrid 에 각 셀값을 적용하는 이중 for문에서 너무 많은 시간이 소요되더군요....
한번에 모든 셀을 불러들일 수 있는지????
어찌해야 할지 잘 모르겠습니다...
선배님들의 조언 부탁드립니다....
|