How to use Excel Alignment with DotNet variable

Bogdan_UABogdan_UA Member Posts: 15
edited 2014-05-29 in NAV Three Tier
Hello!
I try to understand how to use variable with DataType DotNet, when we create export to Excel.
Rather, what we can use instead this code, etc.?

XlWrkSht.Range(xlColID + xlRowID).HorizontalAlignment := -4108; //Center
XlWrkSht.Range(xlColID + xlRowID).HorizontalAlignment := -4131; //Left
XlWrkSht.Range(xlColID + xlRowID).HorizontalAlignment := -4152; //Right

Maybe someone did it.

Thank you!

Comments

  • geordiegeordie Member Posts: 655
    Hi, I suppose you are running NAV 2013: the main difference with previous version is that inside Excel Buffer table Excel .NET interoperabilities are used, which "wrap" standard functions. So, not all Excel features are available to use but only those ones published through .net interop.

    My solution was create a custom copy of Excel Buffer working with OpenXml (I followed this article), which can be expandend with all the features needed.

    Hope it helps.
  • Bogdan_UABogdan_UA Member Posts: 15
    Yes, I am use NAV 2013 R2.
    I thought that we can use this function with DotNet:(
    I hope Microsoft implement it in NAV 2014:)

    It helped. Thank you for answer!
  • Maria-SMaria-S Member Posts: 90
    Hi geordie!

    Can you please explain a little more about aligning text working with OpenXml?

    I do not know even how to start :(
  • geordiegeordie Member Posts: 655
    Hi, I think you can refer to the exhaustive posts of Kauffmann and Gunnar for an complete explanation. Basically you need to:

    * Download and deploy the ClosedXML dll.
    * Replace in the code the references of variables XlWrkBk, XlWrkSht, XlRange, etc...
    * Upgrade the code interface with these new DotNet components.
    * Add a new field in Excel Buffer table to be managed in CreateSheet function in order to set cells alignment.

    Hope it helps!
  • Maria-SMaria-S Member Posts: 90
    So it seems using ClosedXML is general approach when nice excel is needed.

    And, as a developer, if I want to use it, I must convince my customer to install this tool on their server.

    Ok, understood.

    Thank you geordie!
Sign In or Register to comment.