|
Variant excel_app;
Variant excel_book, excel_books;
Variant excel_sheet;
Variant cells;
Variant Data;
WideString ExcelData[5];
WideString ExFileName;
excel_app = Variant::CreateObject("excel.application");
excel_app.OlePropertySet("Visible", (Variant)false);
excel_books = excel_app.OlePropertyGet("Workbooks");
excel_book = excel_books.OleFunction("Add", 1);
excel_sheet = excel_book.OlePropertyGet("ActiveSheet");
TDateTime DT = Now();
ExFileName = ExtractFilePath(Application->ExeName) + "Alarm_Excel\\" + DT.FormatString("yyyymmdd") + ".xls";
for (int i = 1; i <= BigSGAlarm->RowCount; i++) {
cells = excel_sheet.OlePropertyGet("Cells", i, 1 );
cells.OlePropertySet("Value", WideString(BigSGAlarm->Cells[0][i-1]));
cells = excel_sheet.OlePropertyGet("Cells", i, 2 );
cells.OlePropertySet("Value", WideString(BigSGAlarm->Cells[1][i-1]));
cells = excel_sheet.OlePropertyGet("Cells", i, 3 );
cells.OlePropertySet("Value", WideString(BigSGAlarm->Cells[2][i-1]));
cells = excel_sheet.OlePropertyGet("Cells", i, 4 );
cells.OlePropertySet("Value", WideString(BigSGAlarm->Cells[3][i-1]));
cells = excel_sheet.OlePropertyGet("Cells", i, 5 );
cells.OlePropertySet("Value", WideString(BigSGAlarm->Cells[4][i-1]));
}
excel_book.OleProcedure("SaveAs" ,ExFileName); // <--이부분
excel_book.OleFunction("Close", (Variant)False);
excel_sheet = Unassigned;
excel_book = Unassigned;
excel_app.OleFunction("Quit");
excel_app = Unassigned;
---------------------------------------------
이 처럼 엑셀로 알람 파일을 만들고 있습니다.
프로그램이 하루에 한번씩 실행되고 종료되면 아~무 문제가 없겠지만
중간에 프로그램을 종료했을경우 위와 같이 엑셀 파일이 만들어집니다..
다시 프로그램을 실행했을경우
기존에 만들어진 파일의 그 다음줄 부터 알람 내용을 저장하도록 하고싶어요..
기존 파일이 있습니다 다시 저장하시겠습니까?? 묻는 팝업창도 안나오게 하고 싶은데 방법이 없을까요?
|