Skip to main content

NAV 2013 R2 - Import Excel File Using Excel Buffer.

Hi All,


This article is based on a friend request. The Requirement was to import the data in a table From an Excel File.

Most of us know this feature is there in standard objects of Microsoft Dynamics NAV from a long time.

If you are one of those who don't know about it please go through the article.


Just for the Demo suppose i have a table where with following fields as shown below -


And the file that i want to import looks like something as shown below -


The Target is to import the data from excel in the Navision Table.

I have Created a Page to view imported entries and on the same page there is an action of Import From Excel.

For Importing data from Excel we will be using Standard ReadSheet Function in Excel Buffer Table in a Report. The Report will be Processing Only and will have options to Add the Entries or Replace the Entries.

Below is the code that have been used to achieve desired result -

First the Report Checks the option that user selected in Request Page of Replacing Entries or Adding Entries.

Then using Standard Function of Excel Buffer the Excel File Selected by User is Opened.

Then Using ReadSheet Function Excel Buffer Reads the Data in Selected Excel File.

Then System using a function try to get No. of Rows and Column in Selected Excel Sheet.

As First Row in Our Case Contain Caption, so it start inserting data in table from Row No 2 To Last Row


What system does in Function GetLastRowandColumns -

What system Does in Function Insert Data -

System read the data in a row and assign it to actual table fields.


To Open Excel File and Sheet Selection Code on Request Page is -


Now let's try to execute the process from the Page -

1. Select Import From Excel and Select Option to Add / Replace Entries. Once Clicked Ok System will ask for the Excel File to Import, as shown below -


Once File is selected and Excel File have multiple sheets, System will prompt to select the sheet also.
If everything goes well a confirmation message will appear and the data will be updated as shown below.


Hope you like to article and it being used by you in any business scenarios.

For Objects used in Demo please download same from my SkyDrive.

File Name - Saurav.NAV#ExcelImport.rar

Stay Tuned for More.

Regards,
Saurav Dhyani

Comments

  1. Sorry but this is not helpful for someone who is not a good nav developer.

    ReplyDelete
    Replies
    1. I totally agree a new developer still require to learns basics of NAV first and look for processes which require customization and then it will make sense.

      Sorry i was unable to write something that it did not help you.

      Delete
  2. Great blog. I created a report and its working fine. I am facing the uploading time issue. I have around 800 lines and some validations before inserting the record in database. Report is taking too much time. For 800 it took around an hour or more which I feel is not a feasible solution. Any help in that?

    ReplyDelete
    Replies
    1. @Ramiz Arshad,
      I totally agree for these many lines. I would suggest to use Xmlport to import data.

      Delete

Post a Comment

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searching for the error i figured out the issue was due to - Design change in NA

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.