O'Reilly logo

Microsoft Dynamics NAV 2009 Programming Cookbook by Matt Traxinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. Create a new report based on the Customer table using the Report Generation Wizard.
  2. Add the No., Name, and Balance fields.
  3. Add the following global variables:

    Name

    Type

    Subtype

    ExcelBuf

    Record

    Excel Buffer

    PrintToExcel

    Boolean

     
  4. The ExcelBuf variable should be Temporary.
  5. Add a function named MakeExcelInfo.
  6. Add the following code the function:
    ExcelBuf.SetUseInfoSheed; ExcelBuf.AddInfoColumn(FORMAT('Company Name'), FALSE,'',TRUE,FALSE,FALSE,''); ExcelBuf.AddInfoColumn(COMPANYNAME,FALSE,'',FALSE,FALSE, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required