In Dynamics AX, data can be retrieved from Excel files with the help of the same SysExcel
classes that we used to create Excel files. These classes provide a simple interface for developers to access and read data in Excel files.
In this recipe, we will demonstrate how to read Excel files using the SysExcel
classes. We will read the file created in the previous recipe and display its contents in the Infolog window.
Carry out the following steps in order to complete this recipe:
In the AOT, create a new job named
ReadExcelFile
with the following code snippet (replace the filename with your own):static void ReadExcelFile(Args _args) { SysExcelApplication excel; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; COMVariantType type; int row; CustAccount account; CustName name; ...