21 March 2011

Microsoft Office Web Component

Recently I came across the software tool Microsoft Office Web Components.
Basically it allows spreadsheets, pivot tables and graphs to be placed in HTML pages.
It is the last element - Graphs; that I will consider here.

Recognising the power of graphs in a management report, it has previously been possible to prepare a graph; say in Excel; and save it as an image file to be placed in a HTML page. But obviously, this takes time and requires co-ordination.

With Microsoft Office Web Component (OWC) and using your prefered script language - VBScript, JavaScript, etc. web pages can be built to provide management reports that automatically draw data from a background database and at the same time present a graph using that data within the HTML page. Thus, making the process as automated as possible.
With Acceptum Business Software for example it is possible to prepare a HTML page that provides the outline of a management report. Built into the HTML are SQL Select statements and Table Look Up commands that are evaluated prior to the HTML being sent to Internet Explorer. Using OWC and VBScript, graphs can be placed in the management report giving the data more vibrance. Having got the data into a temporary HTML file, it can be saved to a central folder on a server for all managers to review. This way the database is only queried once and provides a "frozen" image to which all can refer.

So lets take a look at an example web page (brackets changed to get it to display).

[BODY topMargin=1]
[script language="VBScript"]

Dim oChart1, categories, bud_get, act_ual, var_iance, c1 '***************************************************************
Sub Window_Onload
' Clear the contents of the chart workspace.
' This removes any old charts that may already exist
' and leaves the chart workspace
' completely empty. One chart object is then added.
ChartSpace1.Clear
ChartSpace1.Charts.Add
Set c1 = ChartSpace1.Constants

' Add a series to the chart.
ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SeriesCollection.Add
' Set the series caption (the text that appears in the legend).
ChartSpace1.Charts(0).SeriesCollection(0).Caption = "Revenue Year to Date"
categories = "Actual"

' Set the categories for the first series (this collection is zero-based)
ChartSpace1.Charts(0).SeriesCollection(0).SetData c1.chDimCategories, c1.chDataLiteral, categories

act_ual = CLng("&$TABLELOOKUP("results", "SCORECARD", "company = m.gccomp and id = 'A005' ", "")$&")
ChartSpace1.Charts(0).SeriesCollection(0).Caption = categories
ChartSpace1.Charts(0).SeriesCollection(0).SetData c1.chDimCategories, c1.chDataLiteral, categories
ChartSpace1.Charts(0).SeriesCollection(0).SetData c1.chDimValues, c1.chDataLiteral, act_ual

categories = "Budget"
bud_get = CLng("&$TABLELOOKUP("results", "SCORECARD", "company = m.gccomp and id = 'A001' ", "")$&")
ChartSpace1.Charts(0).SeriesCollection(1).Caption = categories
ChartSpace1.Charts(0).SeriesCollection(1).SetData c1.chDimCategories, c1.chDataLiteral, categories
ChartSpace1.Charts(0).SeriesCollection(1).SetData c1.chDimValues, c1.chDataLiteral, bud_get

categories = "Variance"
var_iance = CLng("&$TABLELOOKUP("results", "SCORECARD", "company = m.gccomp and id = 'A009' ", "")$&")
ChartSpace1.Charts(0).SeriesCollection(2).Caption = categories
ChartSpace1.Charts(0).SeriesCollection(2).SetData c1.chDimCategories, c1.chDataLiteral, categories
ChartSpace1.Charts(0).SeriesCollection(2).SetData c1.chDimValues, c1.chDataLiteral, var_iance

' Format the chart to have a legend
ChartSpace1.Charts(0).HasLegend = True
ChartSpace1.Charts(0).HasTitle = True
ChartSpace1.Charts(0).Legend.Position = c1.chLegendPositionTop
ChartSpace1.Charts(0).Title.Caption = "Revenue Year to Date"
'ChartSpace1.Charts(0).Axes(c1.chAxisPositionLeft).MajorUnit = 1000
set c1 = nothing

End Sub
'**************************************************
Sub Window_OnUnload
'Executed when window is closed.
Set oChart1 = nothing
Set chartspace1 = nothing
End Sub
'*************************************************
[/script]

[H2]Year To Date upto Period 6[/H2]
Year to Date Revenue is £ &$TABLELOOKUP("results", "SCORECARD", "company = m.gccomp and id = 'A005' ", "")$& [br /]
compared to Budget of £ &$TABLELOOKUP("results", "SCORECARD", "company = m.gccomp and id = 'A001' ", "")$& [br /]
giving a Variance of £ &$TABLELOOKUP("results", "SCORECARD", "company = m.gccomp and id = 'A009' ", "")$& .[br /]

[object id='ChartSpace1' classid=CLSID:0002E546-0000-0000-C000-000000000046 style="width:200;height:200"][/object]
[br /]
[br /]
[H3]Explanation - Revenue Amount[/H3]
&$TABLELOOKUP("notes", "SCORECARD", "company = m.gccomp and id = 'A005' ", "")$&

[H3]Explanation - Budget Amount[/H3]
&$TABLELOOKUP("notes", "SCORECARD", "company = m.gccomp and id = 'A001' ", "")$&

[H3]Explanation - Variance Amount[/H3]
&$TABLELOOKUP("notes", "SCORECARD", "company = m.gccomp and id = 'A009' ", "")$&
[br /]
[br /]
R. Bean - Accountant[br /]
XYZ Ltd. [br /]
[HR class="pwl cblue" align=left SIZE=1]

[BR][/BODY]

Here is an image of the Html page. It is a basic report, a full management report would of course be more complex. But it gives the general idea of what can be achieved. The classid=CLSID:0002E546-0000-0000-C000-000000000046 clause of the object statement may need to vary depending on the installed version of MS OWC.

1 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete