static void ExportDataGeneralJournal(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
GeneralJournalEntry jourEntry;
GeneralJournalAccountEntry jourAccEntry;
FromDate fromDate = mkDate(1,1,2018);
ToDate toDate = mkDate(31,1,2018);
int row = 1;
str fileName;
;
//Filename
fileName = "Document\GeneralAccEntry.xlsx";
//Initialize Excel instance
xlsApplication = SysExcelApplication::construct();
//Open Excel document
//xlsApplication.visible(true);
//Create Excel WorkBook and WorkSheet
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
//Excel columns captions
xlsWorkSheet.cells().item(row,1).value("Date");
xlsWorkSheet.cells().item(row,2).value("Voucher");
xlsWorkSheet.cells().item(row,3).value("PostingType");
xlsWorkSheet.cells().item(row,4).value("LedgerAccount");
row++;
while select jourEntry
join jourAccEntry
where jourEntry.RecId == jourAccEntry.GeneralJournalEntry
&& jourEntry.AccountingDate >= fromDate
&& jourEntry.AccountingDate <= toDate
{
xlsWorkSheet.cells().item(row,1).value(jourEntry.AccountingDate);
xlsWorkSheet.cells().item(row,2).value(jourEntry.SubledgerVoucher);
xlsWorkSheet.cells().item(row,3).value(enum2str(jourAccEntry.PostingType));
xlsWorkSheet.cells().item(row,4).value(jourAccEntry.LedgerAccount);
row++;
}
info("Done");
//Check whether the document already exists
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
//Save Excel document
xlsWorkbook.saveAs(fileName);
//Open Excel document
xlsApplication.visible(true);
//Close Excel
//xlsApplication.quit();
//xlsApplication.finalize();
}