Reading an Excel file
In Dynamics AX, retrieving data from Excel files can be done with the help of the same SysExcel
classes that we used for creating Excel files. The 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 customer file created in the previous recipe and display its content in the Infolog.
How to do it...
Carry out the following steps in order to complete this recipe:
1. In the AOT, create a new job named
ReadExcelFile
with the following code (replace the file name 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; #define.filename(@'C:\temp\customers.xlsx') excel = SysExcelApplication::construct(); workbooks...