|
안녕하세요
엑셀로 데이터를 저장하고있습니다.
한 엑셀파일에 Sheet1과 Sheet2에는 입력한 데이터가 담기게하고,
Sheet3에서는 Sheet1의 데이터를 토대로한 피벗테이블을 만들어놓았습니다.
피벗테이블은 파일을 열때마다 새로고침을 하도록 설정하였는데요,
Variant XL,v0,v1,v2,cells;
XL=Variant::CreateObject("excel.application");
XL.OlePropertySet("Visible",true); //false일때 에러
XL.OlePropertyGet("Workbooks").OleProcedure("Open","C:\\Users\\user\\Desktop\\수납관리\\BOOK.xlsx");
v0=XL.OlePropertyGet("Sheets","Sheet1");
v1=v0.OlePropertyGet("Cells");
Variant vrange = v0.OlePropertyGet("UsedRange");
nRowMax1 = vrange.OlePropertyGet("Rows").OlePropertyGet("Count"); //row갯수
nRowMax1=nRowMax1+1;
cells = v1.OlePropertyGet("Cells",nRowMax1,2);
cells.OlePropertySet("Value",WideString(LabeledEdit2->Text));
cells = v1.OlePropertyGet("Cells",nRowMax1,3);
cells.OlePropertySet("Value",WideString(LabeledEdit5->Text));
cells = v1.OlePropertyGet("Cells",nRowMax1,4);
cells.OlePropertySet("Value",WideString(y+"년"));
cells = v1.OlePropertyGet("Cells",nRowMax1,5);
cells.OlePropertySet("Value",WideString(m+"월"));
cells = v1.OlePropertyGet("Cells",nRowMax1,6);
cells.OlePropertySet("Value",WideString(d+"일"));
cells = v1.OlePropertyGet("Cells",nRowMax1,7);
cells.OlePropertySet("Value",WideString(ExtraData1));
cells = v1.OlePropertyGet("Cells",nRowMax1,8);
cells.OlePropertySet("Value",WideString(ExtraData2));
cells = v1.OlePropertyGet("Cells",nRowMax1,9);
cells.OlePropertySet("Value",WideString(ComboBox2->Text));
cells = v1.OlePropertyGet("Cells",nRowMax1,10);
cells.OlePropertySet("Value",WideString(ComboBox3->Text));
cells = v1.OlePropertyGet("Cells",nRowMax1,11);
cells.OlePropertySet("Value",WideString(ComboBox1->Text));
cells = v1.OlePropertyGet("Cells",nRowMax1,12);
cells.OlePropertySet("Value",WideString(LabeledEdit1->Text));
cells = v1.OlePropertyGet("Cells",nRowMax1,13);
cells.OlePropertySet("Value",WideString(Memo1->Text));
XL.OlePropertySet("DisplayAlerts",false);
XL.OleProcedure("Save");
v0=Unassigned;
v1=Unassigned;
v2=Unassigned;
XL.OleProcedure("Quit");
XL=Unassigned;
위 소스 실행시 Excel visible이 true일때는 큰 문제가 없지만
false일때는 피호출자가 호출을 거부하였다는 메세지와함께 에러가 나고 있습니다.
엑셀을 보여줄때와 보여주지 않을때의 차이가 무엇인지 궁금해서 질문드립니다.
알려주시면 감사하겠습니다!
|