Export Data to Excel Format using codes

duffmoh
Member Posts: 20
Hi All,
Greetings. I found these codings in the Application Designer's Guide, Chapter 16.2. page 402.
I've tried on these codes and it'll only export one record.
Just wondering, is there any other way to export all the records in the table into excel format without using dataport? and using the similar way as mentioned above?
By the way, I'm using 3.01a.
Thanks.
Philip
Greetings. I found these codings in the Application Designer's Guide, Chapter 16.2. page 402.
CREATE(xlApp); xlBook := xlApp.Workbooks.Add(-4167); xlSheet := xlApp.ActiveSheet; xlSheet.Name := 'Personnel Expenses'; xlSheet.Range('A2').Value := 'Administration'; xlSheet.Range('A3').Value := "G/L Entry".Amount;
I've tried on these codes and it'll only export one record.
Just wondering, is there any other way to export all the records in the table into excel format without using dataport? and using the similar way as mentioned above?
By the way, I'm using 3.01a.
Thanks.
Philip
0
Comments
-
Hello,
Loop through the records as usual and make a variable 'counter' (type = integer) and add one to the counter and dynamicaly set the row in excel:
xlSheet.Range('A1').Value := 'Administration';
IF "G/L Entry".FIND('-') THEN BEGIN
REPEAT
Counter := Counter + 1;
xlSheet.Range('B' + FORMAT(Counter)).Value := "G/L Entry".Amount;
UNTIL "G/L Entry".Next := 0;
END;
I did not test it but with this code youre close it thinkIn a world without Borders or Fences, who needs Windows and Gates?0 -
right Jan Peter,
I don't want to bitch about your code, but I thinks you could improve it a bit by using a "INCSTR" instead of an integer variable.Cell[1] := 'A1'; Cell[2] := 'B1'; xlSheet.Range(Cell[1]).Value := 'Entry No.'; // Just a sample xlSheet.Range(Cell[2]).Value := 'Amount'; IF "G/L Entry".FIND('-') THEN REPEAT FOR i := 1 to ARRAYLEN(Cell) DO Cell[i] := INCSTR(Cell); xlSheet.Range(Cell[1]).Value := "G/L Entry"."Entry No."; xlSheet.Range(Cell[2]).Value := "G/L Entry".Amount; UNTIL "G/L Entry".Next := 0;
* Code haven't been tested."Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."0 -
Sorry Emil, i think you should review your code, there are alot of mistakes in it wich are confusing.
- you are doing INCSTR(Cell) and Cell is an array?
- for every record you fill the array with the same data? Can be done before the repeat.
- you are always filling the same cells (A1 and B1)?
- INCSTR is a more lengthy routine then format because it has to search for te start of the number, convert it to integer, increase it and then convert it back to text. (ok who will notice on todays machines :? )
I don't think it is an improvent.
Don't make easy things difficult.In a world without Borders or Fences, who needs Windows and Gates?0 -
Hi JanPieter,
Thanks for your help!! Your codings works0 -
Youre welcome.
... if your goal is to create a chart in excel you might want to have a look at Embedded Controls ...In a world without Borders or Fences, who needs Windows and Gates?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