Sending data to the Excel automation server
The automation datatype in C/AL is frequently used in practice for communication with Microsoft Office applications that export their API through automation servers.
Now we will export the contents of the Customer table from a codeunit
using the COM automation library.
How to do it....
Create a new
codeunit
in the object designer. This will be the object exporting data through an automation server.Triggering
OnRun
of thecodeunit
will instantiate the automation server and iterate on records of the Customer table to export each of them. First declare local variables in the trigger:Name
DataType
Subtype
Customer
Record
Customer
ExcelApp
Automation
Microsoft Excel 16.0 Object Library.Application
Workbook
Automation
Microsoft Excel 16.0 Object Library.Workbook
Worksheet
Automation
Microsoft Excel 16.0 Object Library.Worksheet
RowNo
Integer
Note
The Microsoft Excel 16 Object Library version in variable declarations corresponds to...