Skip to main content

Navision Export To Excel with Merge Cell Function

Hi all,

While developing reports in classic client with Export to Excel Enabled, client wants to have Header cell merged. This is mostly faced issue.

Resolution -
What i did is that i added a function in Excel Buffer table which merge specified cell.

Function -

PROCEDURE MergeRange(FromRow : Integer;FromCol : Integer;ToRow : Integer;ToCol : Integer);
VAR
  FromRec : Record 370;
  ToRec : Record 370;
BEGIN
  FromRec.VALIDATE("Row No.",FromRow);
  FromRec.VALIDATE("Column No.",FromCol);
  ToRec.VALIDATE("Row No.",ToRow);
  ToRec.VALIDATE("Column No.",ToCol);
  XlWrkSht.Range(FromRec.xlColID + FromRec.xlRowID + ':' + ToRec.xlColID + ToRec.xlRowID).Merge;
END;



Function Definition -

1) Function contain 4 Parameters - From Row No, From Column No, To Row No, To Column No., which specify the Cells that need to merge.

2) After you created the sheet and before you save it away or give the user control call that function.

As per Promod Request here is a sample example of how to use the function-

* Its just a sample code where i hardcoded the column and Row Numbers, you can change it to dynamic as per your requirment.

This is what i was getting output earlier using this function -


Now what i wanted is to merge the cells so Blog name comes in one cell. Below is the code that i have written in my report.


And here is the output that i get after that -


@pramod patil i hope this is what you wanted. Let me know if you have any issues.

Thanks & Regards,
Saurav Dhyani
http://saurav-nav.blogspot.in/

Comments

  1. Very Help Full Dude......!
    Regards
    Shravan Kumar
    Nav Developer
    Hyderabad,Ind

    ReplyDelete
  2. Plz send how to use this code. I can't use it I face error at run time when I call this code!

    ReplyDelete
    Replies
    1. Hi Pramod -

      I have updated the Blog entry. Let me know if you have any issues.

      Delete
  3. Thanks, I was use your code, its work very nice!
    But, I want to assign FromRow,FromCol,ToRow,ToCol dynamically. So how I do this?

    ReplyDelete
    Replies
    1. Hi Pramod,

      Can you explain me the exact issue.

      If possible drop me the object at postsaurav@gmail.com, i will have a look.

      Also please explain the whole issue in mail.

      Regards,
      Saurav

      Delete
    2. Thanks friend. Actually I want to add Message after completion of records.SO how we find row number dynamically? Friend,also will you tell me how we can add font to any record like(e.g Times new roman, then size) things when we export to excel? Then also how we add box, colour, etc to fields?

      Delete
    3. Hi Pramod,

      For Font color, size and background color refer to post -
      http://saurav-nav.blogspot.in/2013/02/report-export-to-excel-with-font-colour.html

      Delete
  4. Thanks Saurav an pramod, u helped me understand Excel cell merging!!!....

    ReplyDelete
    Replies
    1. Hi Sachin,

      You are always welcome and it great to hear that my posts are helping someone.

      Regards,
      Saurav

      Delete
    2. This comment has been removed by a blog administrator.

      Delete
  5. How to generate random strings in navision??

    ReplyDelete
  6. hi sir ..
    very helpfull for me..

    ReplyDelete
    Replies
    1. Hi vimal,

      Great to Hear that..

      Regards,
      Saurav Dhyani

      Delete
  7. halo sir, for XlWrkSht where is the definition of this variable

    ReplyDelete
    Replies
    1. @Sharing iimu -
      Which version you are trying this. This is for Classic Dynamics NAV Classic Version and definition of that variable is in the table 370.
      The function need to be added in table 370 where that variable is already available.

      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.