I create a job to delete an excel sheet with content but failed, while it works when the sheet is empty. How to delete a sheet which is not empty?
Belowing is the job.
static void Job1(Args _args)
{
SysExcelApplication excel;
SysExcelWorkbooks books;
SysExcelWorkbook book;
SysExcelWorksheets sheets;
SysExcelWorksheet sheet;
excel = SysExcelApplication::construct();
books = excel.workbooks();
books.open("f:\\test.xlsx");
book = books.item(1);
sheets = book.worksheets();
sheet = sheets.itemFromNum(2);
sheet.delete();
excel.visible(true);
}
*This post is locked for comments