static void generateExcel()
{
SysExcelApplication sysExcelApplication;
SysExcelWorkbooks excelWorkbookCollection;
SysExcelWorkbook excelWorkbook;
SysExcelWorksheets excelWorksheetCollection;
SysExcelWorksheet excelWorksheet;
int i =1;
str filename;
Vendtable vendtable;
TransDate currentdate;
str saveFileName;
str showDate;
Query qr;
currentdate = systemdateget();
ShowDate = date2str(currentdate,123,1,0,2,0,4);
saveFileName = "POReport"+" "+ShowDate;
//info(showDate);
// give the file name and save it to d drive
filename = "d:\\saveFileName.xls"; ???
// initlize the SysExcelApplication instance
sysExcelApplication = SysExcelApplication::construct();
//create excel workbook and excel worksheet
excelWorkbookCollection = sysExcelApplication.workbooks();
excelWorkbook = excelWorkbookCollection.add();
excelWorksheetCollection = excelWorkbook.worksheets();
excelWorksheet = excelWorksheetCollection.itemFromNum(1);
//Excel columns captions
// for header
excelWorksheet.cells().item(i,1).value("Order Date");
excelWorksheet.cells().item(i,3).value("Order Number");
excelWorksheet.cells().item(i,4).value("Order Number Line");
excelWorksheet.cells().item(i,5).value("Vendor Code");
excelWorksheet.cells().item(i,6).value("Item: Description");
excelWorksheet.cells().item(i,7).value("Order Q'ty");
excelWorksheet.cells().item(i,8).value("Currency type");
i++;
// fill the excel with TABLE Fields
// TODO
//check the fileName is already exist
if(WinAPI::fileExists(filename))
WinAPI::deleteFile(filename);
// save excel file
excelWorkbook.saveAs(filename);
}
@@ I wrote above code for AX to Excel export. It's working fine.
*** Few things are not working
1. When i run the report 1st time , then it's saved perfectly in above mentioned path. if i again run the report then got the below error
2. I wants to save report with the current system date. that i tried but not working.
Please give me more shed on this.
Thanks!