Hello everyone !
I exportd 2 multi sheet Excel files from ssrs report by code. And now, I want to combine 2 files to 1 with sheets are added in specific possition on new excel file using X++.
I tried to copy 2 sheets from 1 workbookto a new workbook as below
SysExcelApplication application; SysExcelWorkbooks workbooksCollectionInv; SysExcelWorkbooks workbooksCollectionNew; SysExcelWorkbook workbookInv; SysExcelWorkbook workbookNew; SysExcelWorksheets worksheetsCollectionInv; SysExcelWorksheets worksheetsCollectionNew; SysExcelWorksheet worksheetInv; SysExcelWorksheet worksheetNew; Filename fileName = strFmt("C:\\Invoice_%1\\PKL_TB181093-TB181096.xlsx",curUserId()); application = SysExcelApplication::construct(); workbooksCollectionInv = application.workbooks(); //specify the file path that you want to read workbooksCollectionInv.open(filename); workbookInv = workbooksCollectionInv.item(1); worksheetsCollectionInv = workbookInv.worksheets(); worksheetInv = worksheetsCollectionInv.itemFromNum(1); info(worksheetInv.name()); workbooksCollectionNew = application.workbooks(); workbookNew = workbooksCollectionNew.add(); worksheetsCollectionNew = workbookNew.worksheets(); worksheetNew = worksheetsCollectionNew.add(worksheetsCollectionInv.itemFromNum(1), worksheetsCollectionInv.itemFromNum(2)); application.quit();
But get an error
Error executing code: COM (object), method add called with invalid parameters. Stack trace (C)\Classes\COM\add (C)\Classes\SysExcelWorksheets\add - line 16 (C)\Jobs\JobCombineSheets - line 28
I couldn't fix that any help Please?
*This post is locked for comments