Borland
Excel의 셀 범위를 ClipBoard로 Copy 하기
leo21c
2010. 1. 19. 15:25
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Variant xlApp, xlBooks, xlBook, xlSheets, xlSheet, vrange;
xlApp = Variant::CreateObject("Excel.Application");
xlApp.OlePropertySet("Visible",true);
xlBooks = xlApp.OlePropertyGet("Workbooks");
xlBooks.OleProcedure("Open", "C:\\TEST.xls");
xlBook = xlBooks.OlePropertyGet("Item", 1);
xlSheets = xlBook.OlePropertyGet("Worksheets");
xlSheet = xlSheets.OlePropertyGet("Item", 1); //첫번째시트
vrange=xlSheet.OlePropertyGet("Range","A3:C65535"); // 범위지정
vrange.OleProcedure("Select"); // 선택 (범위지정한 부분이 선택됨)
// 복사(클립보드로 복사됨)
xlApp.OlePropertyGet("Selection").OleProcedure("Copy");
// 클립보드 사용
xlApp.OlePropertySet("DisplayAlerts",false); // 경고창 없애기
xlBooks.OleProcedure("Close");
xlApp.OleProcedure("Quit");
}
|