Exporting data using the Excel buffer
NAV contains a wrapper object that allows you to export data to Microsoft Excel. This recipe will show you how to use it in its most common form — exporting a report to Excel.
Getting ready
Microsoft Excel must be installed on the client machine.
How to do it...
Create a new report based on the Customer table using the Report Generation Wizard.
Add the No., Name, and Balance fields.
Add the following global variables:
Name
Type
Subtype
ExcelBuf
Record
Excel Buffer
PrintToExcel
Boolean
The
ExcelBuf
variable should be Temporary.Add a function named
MakeExcelInfo
.Add the following code the function:
ExcelBuf.SetUseInfoSheed; ExcelBuf.AddInfoColumn(FORMAT('Company Name'), FALSE,'',TRUE,FALSE,FALSE,''); ExcelBuf.AddInfoColumn(COMPANYNAME,FALSE,'',FALSE,FALSE, FALSE,''); ExcelBuf.NewRow; ExcelBuf.AddInfoColumn(FORMAT('Report Name'), FALSE,'',TRUE,FALSE,FALSE,''); ExcelBuf.AddInfoColumn(FORMAT('Print Report to Excel'), FALSE,'',FALSE,FALSE,FALSE,''); ExcelBuf...