100% found this document useful (1 vote)
298 views5 pages

Charts Navision

Dynamics Nav Classic Reports have long been dull array of Analytical Information without much, or should I say any, graphical representation of this data. But here how to create a jazzy report propped up with elegant charts.

Uploaded by

Parvez Alam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
298 views5 pages

Charts Navision

Dynamics Nav Classic Reports have long been dull array of Analytical Information without much, or should I say any, graphical representation of this data. But here how to create a jazzy report propped up with elegant charts.

Uploaded by

Parvez Alam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Home Dynamics Nav Displaying Dynamic Charts in Nav Classic Reports

Username

Login
Displaying Dynamic Charts in
Nav Classic Reports
Written by Mayank
Sunday, 26 September 2010 06:16
(0 votes, average 0 out of 5)

Dynamics Nav (Navision) Classic Client Report have long been dull array of Analytical Information without much, or
should i say any, graphical representation of this Data. For any graphical analysis of the data would be done by
exporting the data to excel and then creating charts. But why I ask, when basic Graphs can be embedded into
Classic Reports such as quarterly/monthly sales trends,
So here how to create a jazzy report propped up with elegant charts.
Create a Report to calculate the Sale in quantity of an Item per Quarter for an given year. Store the quarterly sales
figure in 4 Variables as follows
Name Datatype
Latest Articles
Text to Speech :
Making Nav
Speak Out
Displaying
Dynamic Charts
in Nav Classic
Reports
Assigning
Menusuit
Permission
Dynamically -
Part I
Generating
Business Object
Schema in SAP
Business One
Integrating Lotus
Notes Mail and
Dynamics Nav -
Part I
Latest Dynamics
News
Lankan Retailer;
Order Management
Integration to CRM
Microsoft Announces
General Availability
of Dynamics SL 2011
Dont Underestimate
the Impact of
Implementing
Microsoft Dynamics
CRM 2011
A New Microsoft MVP
Benchmark? Fan
Fiction for Dynamics
GP Imagines ERP in
its Full Glory
Search This Site..
Ads by Google
Microsoft Dynamics
Dynamics Solutions
Dynamics AX 2011
Dynamics Nav
Home Business Solutions .NET Development
07/04/11 Displaying Dynamic Charts in Nav Class
extremeengineers.net//22-displaying- 1/5
Name Datatype
1sLC ueclmal
2ndC ueclmal
3rdC ueclmal
4LhC ueclmal
Now the idea is to create an chart using the Excel Automation, export it as a picture and import it to a Temporary
Blob Field and display it on the report.
Create a function with the following automation variable
Name Data1ype
xlWork8k AuLomaLlon
xlWorkShL AuLomaLlon
charLage AuLomaLlon
MyCharL AuLomaLlon
charL8ange AuLomaLlon
xlCharLs AuLomaLlon
xLApp AuLomaLlon
So here's the code that does the magic.
CREATE(XLApp);
XLApp.Visible(FALSE);
XlWorkBk:=XLApp.Workbooks.Add;
XlWorkSht:=XlWorkBk.Worksheets.Add;
XlWorkSht.Range('A1').Value:= '' ;
XlWorkSht.Range('B1').Value := ItemNo ;
XlWorkSht.Range('A2').Value := '1st Quarter' ;
XlWorkSht.Range('B2').Value := "1stQ" ;
XlWorkSht.Range('A3').Value := '2nd Quarter' ;
XlWorkSht.Range('B3').Value := "2ndQ" ;
XlWorkSht.Range('A4').Value := '3rd Quarter' ;
XlWorkSht.Range('B4').Value := "3rdQ" ;
XlWorkSht.Range('A5').Value := '4th Quarter' ;
XlWorkSht.Range('B5').Value := "4thQ" ;
xlCharts := XlWorkSht.ChartObjects;
MyChart := xlCharts.Add(10, 80, 300, 250);
chartPage := MyChart.Chart;
chartRange := XlWorkSht.Range('A1', 'd5');
chartPage.SetSourceData(chartRange);
chartPage.ChartType :=-4102;
chartPage.Export (TEMPORARYPATH+'\excel_chart_export.bmp', 'BMP'); //exporting chart as picture file
tempblob."Primay Key"+=1;
tempblob.Blob.IMPORT(TEMPORARYPATH+'\excel_chart_export.bmp');
tempblob.INSERT;
tempblob.GET(tempblob."Primay Key");
tempblob.CALCFIELDS(Blob);
XlWorkBk.Close(false);
XLApp.Quit;
CLEAR(XLApp);
Now, the first line actually initializes the Excel application.
This
webpage is not
available
The webpage at
http://googleads.g.doubleclick.
net/pagead/ads?client=ca-pub-
3001615429942844&output=html
&h=600&slotname=5376062884
&w=160&lmt=1302155230&flash
=10.2.154&url=http%3A%2F%2F
extremeengineers.net%2Fdyna
mics-nav%2F22-displaying-
dynamic-charts-in-nav-classic-
reports.html&dt=1302175038393
&bpp=4&shv=r20110330&jsv=r2
0110321-
2&prev_slotnames=9057976341
%2C8189565067%2C9114719441
&correlator=1302175038153&fr
m=0&adk=908797468&ga_vid=1
219266030.1302175038&ga_sid=
1302175038&ga_hid=154355638
2&ga_fc=0&u_tz=330&u_his=7&
u_java=1&u_h=800&u_w=1280
&u_ah=770&u_aw=1280&u_cd=
32&u_nplug=16&u_nmime=52&
biw=1263&bih=709&eid=338951
32&ref=https%3A%2F%2Fptop.only.wip.la%3A443%2Fhttp%2Fwww.m
Ads by Google
Chaos Dynamics
Dynamics GP
Dynamics Software
Dynamics Navision
MS Dynamics
07/04/11 Displaying Dynamic Charts in Nav Class
extremeengineers.net//22-displaying- 2/5
Now, the first line actually initializes the Excel application.
CREATE(XLApp);
The second line makes it invisible to the user. That is, excel would be running in the background but no window
would be visible to the user.
XLApp.Visible(FALSE);
The 3rd and 4th line adds a new workbook and worksheet.
XlWorkBk:=XLApp.Workbooks.Add;
XlWorkSht:=XlWorkBk.Worksheets.Add;
Line no 5 to 14 actually add the data that the chart would be generated upon.
XlWorkSht.Range('A1').Value:= '' ;
XlWorkSht.Range('B1').Value := ItemNo ;
XlWorkSht.Range('A2').Value := '1st Quarter' ;
XlWorkSht.Range('B2').Value := "1stQ" ;
XlWorkSht.Range('A3').Value := '2nd Quarter' ;
XlWorkSht.Range('B3').Value := "2ndQ" ;
XlWorkSht.Range('A4').Value := '3rd Quarter' ;
XlWorkSht.Range('B4').Value := "3rdQ" ;
XlWorkSht.Range('A5').Value := '4th Quarter' ;
XlWorkSht.Range('B5').Value := "4thQ" ;
Line no 15 initializes a Chart object in the worksheet.
xlCharts := XlWorkSht.ChartObjects;
Line No 16 adds a new chart in the worksheet. The Add method as you can see takes in 4 parameters, the first two
are the co-ordinates (Top and Left) where the chart would be created, and the last two are the size of the chart in
pixels.
MyChart := xlCharts.Add(10, 80, 300, 250);
At Line No 17, the newly created chart is added to the Chart Page.
chartPage := MyChart.Chart;
Line No 18-19 define the data that the chart would represent
chartRange := XlWorkSht.Range('A1', 'd5');
chartPage.SetSourceData(chartRange);
Line No 20 specifies the Type of chart that would be created, in this case a 3D Pie.
chartPage.ChartType :=-4102;
07/04/11 Displaying Dynamic Charts in Nav Class
extremeengineers.net//22-displaying- 3/5
admin - Tuesday, September 28, 2010 at 09:08 PM
Hi mark,
Thank a ton for your appreciation. Advice Taken :-)
Mark Brummel - Tuesday, September 28, 2010 at 02:22 PM
Very cool! Keep up the good work!
/Mark
admin - Monday, September 27, 2010 at 08:26 PM
Hi Mr Soren,
Thank you for your appreciation, glad that you found it usefull. I'd be bringing in much more, so stay tuned.
Regards
Mayank
Soren - Monday, September 27, 2010 at 06:59 PM
Hi Mayank,
Next at Line No 21, we export the chart to a BMP file.
chartPage.Export (TEMPORARYPATH+'\excel_chart_export.bmp', 'BMP');
Now we need to import this chart image into a temporary blob field to be able to show on the report. For this
purpose we can use Table 99008535 - TempBlob. Line No 22 to 26 do exactly that.
tempblob."Primay Key"+=1;
tempblob.Blob.IMPORT(TEMPORARYPATH+'\excel_chart_export.bmp');
tempblob.INSERT;
tempblob.GET(tempblob."Primay Key");
tempblob.CALCFIELDS(Blob);
Next we close the workbook without saving it, and quit the excel application to avoid creating multiple instances of
it.
XlWorkBk.Close(false);
XLApp.Quit;
CLEAR(XLApp);
So less that 30 lines of codes and without any third party tool, we've a report with great looking charts, what do
you say! The Only pre-requisites for this to work is that MS Excel should be installed on the PC running this function.
If you like this article or if you didn't, do let me know through comments, and if you like it share this with your friends
and colleagues.
07/04/11 Displaying Dynamic Charts in Nav Class
extremeengineers.net//22-displaying- 4/5
Hi Mayank,
great tip for exporting the bitmap from Excel. Looking forward to your future ventures on this blog.
/Soren
Add Comment
2 Like
0
< Prev Next >

Copyright 2011 Extreme Engineers Top
07/04/11 Displaying Dynamic Charts in Nav Class
extremeengineers.net//22-displaying- 5/5

You might also like