Hi everyone. How can I export data from my page, subpage etc. to Excel template that I have gotten for that purpose. I knpw that I should use Excel buffer table but do not know how. Practical steps could be useful since I looked online and found nothing useful.
Thanks!
Answers
https://community.dynamics.com/nav/f/34/t/181214
http://saurav-nav.blogspot.in/2014/01/nav-2013-r2-export-to-excel-report.html
These links help with Reports, but if you check the logic behind and try to understand the code in detail, you will be able to export to excel the data in your page using excel buffer.
Hope it helps.
Ishwar Sharma
My Blogs: Dynamics Community Blog | Blogspot
Connect: Google + | Twitter
for that case i wrote a blog post https://moxie4nav.wordpress.com/2016/08/26/simple-readwrite-excel-data/
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/
This is what I have done.
I created ProcessingOnly report where I created this function:
LOCAL EnterCell(RowNo : Integer;ColumnNo : Integer;CellValue : Text[250];Bold : Boolean;Italic : Boolean;UnderLine : Boolean;Format : Text[30];CellType : Option)
ExcelBuffer.INIT;
ExcelBuffer.VALIDATE("Row No.",RowNo);
ExcelBuffer.VALIDATE("Column No.",ColumnNo);
ExcelBuffer."Cell Value as Text" := CellValue;
ExcelBuffer.Formula := '';
ExcelBuffer.Bold := Bold;
ExcelBuffer.Italic := Italic;
ExcelBuffer.Underline := UnderLine;
ExcelBuffer.NumberFormat := Format;
ExcelBuffer."Cell Type" := CellType;
ExcelBuffer.INSERT;
Then in OnAfterGetRecord I placed this
Travel Order - OnAfterGetRecord()
FileName := 'D:\Putni nalog.xlsx';
SheetName := 'Sheet1';
ExcelBuffer.OpenBook(FileName,SheetName);
EnterCell(2,2,'TravelOrder',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text);
//ExcelBuffer.CreateBookAndOpenExcel('Sheet1','Report',COMPANYNAME,USERID);
//ExcelBuffer.OverwriteAndOpenExistingExcel(FileName);
I want to write on my file Putni nalog.xlsx using
EnterCell(2,2...);
EnterCell(2,5...); etc, depending what I need and in which field in my file do I want to write it.
But when I try using OverwriteAndOpenExistingExcel it gives me error 'The file does not exist'.
What should I use to write on my existing file?
And how can I write some value from my table "Travel Order" since
EnterCell(2,2,TravelOrder."No",FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); for example, simply does not work?
THANK YOU!
That's why i use Excel templates and custom Nav functionality to work with it.
The idea is simple:
1. Nav must not work with format properties - it's responsibility of Excel Template and key user.
2. Use names ranges to define layout (HEADER, LINE_HEADER, LINE, LINE_FOOTER, FOOTER)
3. Use marks to define fields and agree on it with key users - key users should provide it for you.
The sample code below if you're interested don't hesitate to contact me
Nav, T-SQL.
please, how is declared variable "TemplateMgt"?