Export to Excel - Data Display

poppins
Member Posts: 647
Hi everyone,
I am trying to export some data to excel...
I want the data displayed this way:
No. 5
First Name John
I've written a function MakeExcelDataHeader() that generates the data header in the Excel file and called it in the OnPreReport() trigger:
I've also written a function MakeExcelDataBody() that generates the data body in the Excel file and called it in the Employee - OnAfterGetRecord() trigger:
The problem is that I get the data displayed this way:
No.
First Name
5
John
What shall I do to get the data displayed the way I want???
I am trying to export some data to excel...
I want the data displayed this way:
No. 5
First Name John
I've written a function MakeExcelDataHeader() that generates the data header in the Excel file and called it in the OnPreReport() trigger:
ExcelBuf.AddColumn(Employee.FIELDCAPTION("No."),FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.NewRow; ExcelBuf.AddColumn(Employee.FIELDCAPTION("First Name"),FALSE,'',TRUE,FALSE,TRUE,'');where ExcelBuf is a record of type Excel Buffer...
I've also written a function MakeExcelDataBody() that generates the data body in the Excel file and called it in the Employee - OnAfterGetRecord() trigger:
ExcelBuf.AddColumn(Employee."No.",FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.NewRow; ExcelBuf.AddColumn(Employee."First Name",FALSE,'',TRUE,FALSE,TRUE,'');
The problem is that I get the data displayed this way:
No.
First Name
5
John
What shall I do to get the data displayed the way I want???
0
Answers
-
Your code is not quite right.
you print a col1 row1
then
you print col1 row2
then you print col1 row 3
then you print col1 row4
your call to NewRow tells Excel to
CurrentRow := CurrentRow + 1;
CurrentCol := 0;
That sets the currentcol back to 0
you want to be on col2
I hope this helps0 -
HI poppins,
The code is correct but you don't need MakeExcelDataHeader() Function.
As per your requirement you just require the MakeExcelDataBody() and the code will be -ExcelBuf.AddColumn(Employee.FIELDCAPTION("No."),FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.AddColumn(Employee."No.",FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.NewRow; ExcelBuf.AddColumn(Employee.FIELDCAPTION("First Name"),FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.AddColumn(Employee."First Name",FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.NewRow;
The output will be -
No. 5
First Name John
No. 10
First Name Saurav
Let me know if you have any issues.
Thanks & Regards,
Saurav Dhyani
Do you Know this About NAV?
Connect - Twitter | Facebook | Google + | YouTube
Follow - Blog | Facebook Page | Google + Page0 -
Thank you guysSPost29 wrote:Your code is not quite right.
you print a col1 row1
then
you print col1 row2
then you print col1 row 3
then you print col1 row4
your call to NewRow tells Excel to
CurrentRow := CurrentRow + 1;
CurrentCol := 0;
That sets the currentcol back to 0
you want to be on col2
I hope this helps
Yes...I was wondering if I can make it go back to the first line of the Excel file to write the values corresponding to each column of the header...postsaurav wrote:HI poppins,
The code is correct but you don't need MakeExcelDataHeader() Function.
As per your requirement you just require the MakeExcelDataBody() and the code will be -ExcelBuf.AddColumn(Employee.FIELDCAPTION("No."),FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.AddColumn(Employee."No.",FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.NewRow; ExcelBuf.AddColumn(Employee.FIELDCAPTION("First Name"),FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.AddColumn(Employee."First Name",FALSE,'',TRUE,FALSE,TRUE,''); ExcelBuf.NewRow;
The output will be -
No. 5
First Name John
No. 10
First Name Saurav
Let me know if you have any issues.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