Excel Buffer with extended formatting

AlexDen
Member Posts: 86
Hello all,
I would like to share a solution that allows to export data to excel via "Excel Buffer" with extended formatting: alignment, cell borders and etc.
You can find source code with code samples on GitHub:
It doesn't require any additional components, it uses only OpenXML components for extended formatting.
This solution is developed for Nav 2017 version, but I think that some functions can be easily transferred to other versions.
I would like to share a solution that allows to export data to excel via "Excel Buffer" with extended formatting: alignment, cell borders and etc.
You can find source code with code samples on GitHub:
It doesn't require any additional components, it uses only OpenXML components for extended formatting.
This solution is developed for Nav 2017 version, but I think that some functions can be easily transferred to other versions.
3
Comments
-
Works in NAV 2018. Only need changing the dotnet nav openxml variables from version 10.0.0.0 to 11.0.0.0United Kingdom0
-
@AlexDen
By a chance... Have you tried to implement AutoFit for your openxml solution?
I found this and it looks like it is not too easy...
https://stackoverflow.com/questions/31197038/how-to-autofit-excel-column-using-openxml-package0 -
Hi,
No, I haven't tried it.
You can try to find cell with maximum number of characters in the column and set width for it as STRLEN("Cell Value as text")*7+5 (if you use default font size).
But it will not work for formulas as the result will be known only after calculation.0 -
Thanks anyway
Your solution woks great. I updated it to match latest BC version of standard Excel Buffer. Now every object using standard can switch to using new solution only by changing table number of Buffer variable.
AutoFit is a 'nice to have' anyway.
It is a bit overkill as to do it in proper way we would need to wait until CloseBook and then re-open it, re-read with recalculation of all formulas and then find a proper width/height for each column/row.
Does not sound like worth the hassle.
Another way would be to wait for closing the book and re-open it in actual Excel at client - and then just call auto fit for all sheets - but I prefer to stay within Open XML.
Cheers0 -
Hi guys, may I know how to use excel buffer to set column width and wrap text for a specific column? I using BC version0
-
Please vote on this idea to have these awesome properties on BC SaaS as well:
https://experience.dynamics.com/ideas/idea/?ideaid=268af51c-6bb1-ee11-92bd-000d3a0f8799
0 -
It seems Microsoft has no plans to extend the current "Excel Buffer" functionality. So, I implemented an example of how it is possible to create an Excel file in BC Cloud with extended formatting.
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions