Skip to main content

Microsoft Dynamics NAV 2016 - Save Export to Excel

Hi All,

If you remember we discussed in Past about Saving Excel File in NAV 2013 R2. This article is Re-writing the Same Article for Microsoft Dynamics NAV 2016.

If you are looking for same solution for Microsoft Dynamics NAV 2013 and NAV 2013 R2 please refer article -  NAV 2013 & NAV 2013 R2 - Save Export to Excel

This article discuss the steps required for Microsoft Dynamics NAV 2016.

1. SETUP -

Create a New Field in Table 409 SMTP Mail Setup for Specifying the Path. Add the Field on Page 409 SMTP Mail Setup as shown below.

2. Code Changes -

Changes in Table 370 Excel Buffer -

a. Created Two Functions CreateBookAndSaveExcel & SaveExcel.

b. Function CreateBookAndSaveExcel Definition- 
 * Copy of CreateBookandOpenExcel with some code changed.


c. Function SaveExcel Definition.

IF OpenUsingDocumentService('') THEN

IF NOT PreOpenExcel THEN

FileNameClient := FileManagement.DownloadTempFile(FileNameServer);
FileNameClient := FileManagement.MoveAndRenameClientFile(FileNameClient,'Book1.xlsx',SmtpSetup."Save Excel Report");
Variables in Function Save Excel-

Name               DataType         Subtype
FileNameClient Text
SmtpSetup         Record           SMTP Mail Setup

3. Let's Execute By Running the Report with new Function.

Create a new report which export data from customer table and save the File is the path specified in the SMTP Setup. As shown below instead of using CreateBookAndOpenExcel we use CreateBookAndSaveExcel.

And once we execute the Report, the report is saved in the Path where we setup in the SMTP Setup.

Objects can be downloaded from - Dynamics User Group or Skydrive.

File Name  - NAV 2016_Save to Excel

** If you are planning to merge it on a custom database then the attachment have before and after the text files are available in the download files.

You can also make it more generic by passing File Name from the Report Itself.

Your comments and feedback are welcome. Stay tuned for more.

Saurav Dhyani


Popular posts from this blog

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

Dynamics 365 Business Central 2021 release wave 2 (BC19) Released.

Hi Readers, As we all were expecting Microsoft have Released Business Central 2021 Release Wave 2 Today a.k.a BC19. In this article we will see what all is announced with the General Availability.  Starting Today Customers & Partners can start using Business Central 19. #msdyn365bc #bc19

MSDYN365BC - Data Upgrade To Microsoft Dynamics 365 Business Central on premises.

Hi Readers, We have already talked about the number of steps for upgrading to Business Central on Premises from different NAV versions. After that article, I received multiple requests for an article which list down steps for Data Migration. In this article, we will discuss steps of data migration to MSDYN365BC (on-Prem) from NAV 2017. For this article, I am considering a Cronus Demo Database without any customization. For an actual upgrade project, we will have to complete object merge using compare and Merge process. After the Merge Process, the next step is data migration. Let's discuss those steps. Direct Upgrade to Microsoft Dynamics 365 Business Central (on-Prem) is from following versions - 1. NAV 2015. 2. NAV 2016. 3. NAV 2017. 4. NAV 2018.