exporting table data using the Microsoft® Excel® spreadsheet format. However,
sometimes it may be necessary to perform similar Microsoft Excel data import
and export functions from a custom function. Often, this can be done using
Comma Separated Value (CSV) files and the CommaIO class, but sometimes
using XLS or XLSX formatted files is a requirement. To make this possible,
there are various classes to perform Microsoft Excel integration. These all start
with the prefix SysExcel and can be found in the Class branch of the AOT.
The following is an example of some X++ code that integrates with an XLS file,
and pulls a value from a specific cell.
1 2 3 4 5 6 7 8 9 10 11 12 | SysExcelApplication ExcelApp; Str cellValue; ; //Creates the instance ExcelApp = SysExcelApplication::construct(); //Opens the file ExcelApp.workbooks().open('c:\test.xls'); //Shows the value of the selected cell. cellValue = ExcelApp.activeSheet().cells().item(1, 1).value().toString(); //both columns and rows are referenced numerically, eg. A=1, B=2 etc info(strfmt("Value of cell A1 = %1", cellValue)); |
Best Regards,
Hossein Karimi
No comments:
Post a Comment