How to excel export with information from different tables

DappreStrijder
Member Posts: 8
Hi mubuso followers,
I have a question for my following problem and code. This code will export a Excel list with different Row's and information on different tables.
Now RowNo 6 and 14 will not set data and will be empty. Does someone knows why? Thanks for answer.
IF ExportToExcel THEN BEGIN
RowNo := RowNo + 1;
WITH ExcelBuf DO BEGIN
// Print Columnheaders.
IF RowNo = 1 THEN BEGIN
EnterCell(RowNo,1,'Test formulier',TRUE,FALSE);
RowNo := RowNo + 2;
EnterCell(RowNo,1,'Status',TRUE,FALSE);
EnterCell(RowNo,2,'Productieorder',TRUE,FALSE);
EnterCell(RowNo,3,'Vestiging',TRUE,FALSE);
EnterCell(RowNo,4,'Bew.plannr.',TRUE,FALSE);
EnterCell(RowNo,5,'Artikelnr.',TRUE,FALSE);
EnterCell(RowNo,6,'Productielijn',TRUE,FALSE);
EnterCell(RowNo,7,'Omschrijving',TRUE,FALSE);
EnterCell(RowNo,9,'Begindatum',TRUE,FALSE);
EnterCell(RowNo,10,'Aantal',TRUE,FALSE);
EnterCell(RowNo,11,'Kosten',TRUE,FALSE);
EnterCell(RowNo,12,'Bedrag',TRUE,FALSE);
EnterCell(RowNo,13,'Opmerkingen',TRUE,FALSE);
EnterCell(RowNo,14,'Sorteringregelnummer',TRUE,FALSE);
RowNo := RowNo + 1;
END;
// Export Data
EnterCell(RowNo,1,FORMAT (Status),FALSE,FALSE);
EnterCell(RowNo,2,"Prod. Order No.",FALSE,FALSE);
EnterCell(RowNo,3,"Location Code",FALSE,FALSE);
EnterCell(RowNo,4,"Routing No.",FALSE,FALSE);
EnterCell(RowNo,5,"Item No.",FALSE,FALSE);
EnterCell(RowNo,6,FORMAT (ProductionBatchLine."Prod. Batch No."),FALSE,FALSE);
EnterCell(RowNo,7,Description,FALSE,FALSE);
EnterCell(RowNo,8,"Description 2",FALSE,FALSE);
EnterCell(RowNo,9,FORMAT ("Starting Date"),FALSE,FALSE);
EnterCell(RowNo,10,FORMAT (Quantity),FALSE,FALSE);
EnterCell(RowNo,11,FORMAT (LineCost),FALSE,FALSE);
EnterCell(RowNo,12,FORMAT (LineAmount),FALSE,FALSE);
EnterCell(RowNo,13,ProductionOrder.Remark,FALSE,FALSE);
EnterCell(RowNo,14,FORMAT (ProductionBatchLine."Sorting Line No."),FALSE,FALSE);
I have a question for my following problem and code. This code will export a Excel list with different Row's and information on different tables.
Now RowNo 6 and 14 will not set data and will be empty. Does someone knows why? Thanks for answer.
IF ExportToExcel THEN BEGIN
RowNo := RowNo + 1;
WITH ExcelBuf DO BEGIN
// Print Columnheaders.
IF RowNo = 1 THEN BEGIN
EnterCell(RowNo,1,'Test formulier',TRUE,FALSE);
RowNo := RowNo + 2;
EnterCell(RowNo,1,'Status',TRUE,FALSE);
EnterCell(RowNo,2,'Productieorder',TRUE,FALSE);
EnterCell(RowNo,3,'Vestiging',TRUE,FALSE);
EnterCell(RowNo,4,'Bew.plannr.',TRUE,FALSE);
EnterCell(RowNo,5,'Artikelnr.',TRUE,FALSE);
EnterCell(RowNo,6,'Productielijn',TRUE,FALSE);
EnterCell(RowNo,7,'Omschrijving',TRUE,FALSE);
EnterCell(RowNo,9,'Begindatum',TRUE,FALSE);
EnterCell(RowNo,10,'Aantal',TRUE,FALSE);
EnterCell(RowNo,11,'Kosten',TRUE,FALSE);
EnterCell(RowNo,12,'Bedrag',TRUE,FALSE);
EnterCell(RowNo,13,'Opmerkingen',TRUE,FALSE);
EnterCell(RowNo,14,'Sorteringregelnummer',TRUE,FALSE);
RowNo := RowNo + 1;
END;
// Export Data
EnterCell(RowNo,1,FORMAT (Status),FALSE,FALSE);
EnterCell(RowNo,2,"Prod. Order No.",FALSE,FALSE);
EnterCell(RowNo,3,"Location Code",FALSE,FALSE);
EnterCell(RowNo,4,"Routing No.",FALSE,FALSE);
EnterCell(RowNo,5,"Item No.",FALSE,FALSE);
EnterCell(RowNo,6,FORMAT (ProductionBatchLine."Prod. Batch No."),FALSE,FALSE);
EnterCell(RowNo,7,Description,FALSE,FALSE);
EnterCell(RowNo,8,"Description 2",FALSE,FALSE);
EnterCell(RowNo,9,FORMAT ("Starting Date"),FALSE,FALSE);
EnterCell(RowNo,10,FORMAT (Quantity),FALSE,FALSE);
EnterCell(RowNo,11,FORMAT (LineCost),FALSE,FALSE);
EnterCell(RowNo,12,FORMAT (LineAmount),FALSE,FALSE);
EnterCell(RowNo,13,ProductionOrder.Remark,FALSE,FALSE);
EnterCell(RowNo,14,FORMAT (ProductionBatchLine."Sorting Line No."),FALSE,FALSE);
0
Answers
-
If you are referring to "ProductionBatchLine"
You need a "GET"
https://msdn.microsoft.com/en-us/library/dd301056.aspx1 -
Thanks for reply to my problem. Where can i set the GET code? Before or after the ExcelExport function?
EnterCell(RowNo,6, ProductionBatchLine.GET('Prod. Batch No.'),FALSE,FALSE);
I just edit this line and it will give a type conversion message back.0 -
...
ProductionBatchLine.GET(<key fields>);
EnterCell(RowNo,6,FORMAT (ProductionBatchLine."Prod. Batch No."),FALSE,FALSE);
...
after that also line 14 should be exported correctly.best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/1 -
...
ProductionBatchLine.GET(<key fields>);
EnterCell(RowNo,6,FORMAT (ProductionBatchLine."Prod. Batch No."),FALSE,FALSE);
...
after that also line 14 should be exported correctly.
ProductionBatchLine.GET(Status);
EnterCell(RowNo,14,FORMAT (ProductionBatchLine."Sorting Line No."),FALSE,FALSE);
will give me " For the expression Option can no type conversion to be performed to a code value. "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