|
Excel에서 Data를 읽어오기 위한 코드인데 OlePropertyGet함수에서 에러가 발생합니다.
예제코드를 봐도 다른게 없는 데 왜 에러가 발생하는 지 모르겠습니다.
이와 같이 Ole를 통해서 값을 얻어오려면 아래 코드 외에 다른 코드가 더 필요한가요?
조언바랍니다.
void __fastcall TLayoutForm::Button1Click(TObject *Sender)
{
AnsiString strData;
Variant ex=Variant::CreateObject("Excel.Application");
Variant xlBooks = ex.OlePropertyGet("Workbooks"); <== Error발생
xlBooks.OleProcedure("Open", "c:\\Test.xls");
Variant awb=ex.OlePropertyGet("ActiveWorkBook");
Variant sh=awb.OlePropertyGet("ActiveSheet");
strData=sh.OlePropertyGet("Cells",1,1).OlePropertyGet("Value");
awb.OleProcedure("Close");
ex.OleProcedure("Quit");
awb=Unassigned;
ex=Unassigned;
}
|