Good day folks,
I am writing an Excel import class in Ax 2012 R2 and I'm having an issue with SysExcelWorkbooks trying to access itemFromNum() with the below error.
Is there anything with the code I have written, which is below?
SysExcelApplication _application; SysExcelWorkbooks _workbooks; SysExcelWorkbook _workbook; SysExcelWorksheets _worksheets; SysExcelWorksheet _worksheet; SysExcelCells _cells; //table names and EDT declaration omitted here COMVariantType _type; int rowCount=1; container _conFilter = ["(.xls)" ,"*.xlsx"]; FileName _fileName; Dialog _dialog; DialogField _dialogfield; _dialog = new Dialog(); _dialog.caption("Pick a file"); _dialogfield = _dialog.addField(extendedTypeStr(FilenameOpen)); _dialog.filenameLookupFilter(conFilter); _dialog.run(); if(_dialog.closedOk()) { _fileName = _dialogfield.value(); _application = SysExcelApplication::construct(); _workbooks = _application.workbooks(); try { _workbooks.open(_fileName); } catch (Exception::Error) { throw error("Could not open the excel upload file"); } _workbook = _workbooks.item(1); _worksheets = _workbook.worksheets(); _worksheet = _worksheets.itemFromNum(1); //more code here }
Thank you in advance for your help!