Generating reports into Excel at night

Shenpen
Member Posts: 386
Sometimes no matter what you do, the slowness of a report due to too much transactions or a complicated request makes it hard to use.
So why not autogenerate reports at night into Excel?
Here is an example inventory list - one for each Location on a separate Worksheet.
So why not autogenerate reports at night into Excel?
Here is an example inventory list - one for each Location on a separate Worksheet.
{ NOTES: sum won't work with any other language than English, change it, f.e. SZUM for Hungarian Variables: Name DataType Subtype Length Excel Automation 'Microsoft Excel 11.0 Object Library'.Application Workbook Automation 'Microsoft Excel 11.0 Object Library'.Workbook Worksheet Automation 'Microsoft Excel 11.0 Object Library'.Worksheet } IF NOT CREATE(Excel,TRUE) THEN ERROR('FSCK!!!'); Excel.Visible(FALSE); Workbook := Excel.Workbooks.Add; CLEAR(Loc); IF Loc.FIND('-') THEN REPEAT Worksheet := Workbook.Worksheets.Add; Worksheet.Name:=Loc.Code; CLEAR(Item); CLEAR(i); IF Item.FIND('-') THEN REPEAT Item.SETFILTER("Location Filter",Loc.Code); Item.CALCFIELDS(Inventory); IF Item.Inventory<>0 THEN BEGIN i+=1; Worksheet.Range('A'+FORMAT(i)).Value:=Item."No."; Worksheet.Range('B'+FORMAT(i)).Value:=Item.Description; Worksheet.Range('C'+FORMAT(i)).NumberFormat:=0; //all other format you can check out with Excel macro recording Worksheet.Range('C'+FORMAT(i)).Value:=Item.Inventory; END; UNTIL Item.NEXT=0; Worksheet.Range('B'+FORMAT(i+2)).Value:='Total:'; Worksheet.Range('C'+FORMAT(i+2)).Value:='=SUM(' + 'C1:'+'C'+FORMAT(i)+ ')'; //language-dependent, in Hungarian Excel it is SZUM UNTIL Loc.NEXT=0; Workbook.SaveCopyAs('D:\locations'+FORMAT(TODAY) +'.xls'); // your date format may cause problems // or if you want to show it: //Excel.Visible(TRUE); //Excel.UserControl(TRUE); CLEAR(Excel);
Do It Yourself is they key. Standard code might work - your code surely works.
0
Comments
-
Define the SUM as TextConstant, so anyone can give his own language if needed.0
-
It seems great !!! it's just an EXCEL report generation?
#-oCarlos0
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