Click here to Skip to main content
15,868,340 members
Articles / Web Development / ASP.NET
Article

ASP.NET Server-Side Charting with OWC11

Rate me:
Please Sign up or sign in to vote.
4.26/5 (22 votes)
9 Jun 20045 min read 287.2K   15K   51   34
ASP.NET Server-Side Charting with OWC11

Introduction

In Client-Server applications, like public commercial websites and private corporate intranet sites, having graphical reports is a common requirement. Typically, when we have some data projecting the periodical sales figures or the profit and loss margins, it is an obvious use case scenario of having graphical reports summarizing the data over a period.

In such scenarios, if it is a windows application we can have some graphics libraries installed on every machine to generate the charts. Where as in web applications the type of browser and the version being used defines the client capability. Here we will have two options to go for:

  • Client-Side Charting &
  • Server-Side Charting

In client side charting, the client should have a charting engine installed in the machine and a supporting browser. This will help in achieving the client side interactive charting as well as Windows functionality within the browsers. But on the downside, will have complexities in the distribution and setup of the client-side software. And usually license costs per client will increase.

Where as in Server-side charting, only the server needs to have the charting engine installed and the charts can be dynamically generated and streamlined to the client in the form of gif or jpeg. Which is cost effective and any normal browser is sufficient at the client-side. But on the downside, Interactive charting cannot be provided and any change in data or refresh at the client leads to a request to the server and the re-generation of the chart.

This article focuses on the Server side charting in ASP.NET environment. And it also emphasizes on the OWC11 object model and different options for binding data to the chart.

Why OWC?

In ASP.Net Environment we have several ways for generating charts. Some of them are as follows:

  • Using the ASP.Net built-in graphics library (System.Drawing).
  • Using the existing charting engines like,
    • MS-Excel Charting engine
    • Crystal Reports Charting engine
    • Dundas Chart Control for ASP.Net
    • Mycos Charts .Net Web Forms Edition
    • netCharting etc.,

Using the ASP.NET built-in graphics library is the most tedious task and demands a lot of design and implementation effort to be kept in explicitly drawing charts and developing required components.

Coming to the existing charting engines, most of them are pretty expensive and will have a foreign look. Out of these, MS Excel Charting engine is the most widely used and one of the most powerful engines available in the market.

As MS Excel is a widely used application, Microsoft came up with a new idea of providing office like functionality on the web. And this is achieved thru “OWC – Office Web Components” which is the center for our current article.

History

The first version of OWC called OWC9 came with MS-Excel 2000 and MS-Front page 2000. OWC9 came with minimum required charting features that can be used by any web application. Later the next version OWC10 or OWCXP came with MS-Office XP. Though there is no much difference in OWC9 and OWC10, the second version holds some interesting functions for optimizing the performance while generating and saving the charts and some new properties for a better look of charts. And now the latest version OWC11 came with MS-Office 2003. This OWC11 has got some really interesting features like XML support etc.,

Licensing Issues

Regarding the licensing issues of OWC11, we should have license of either MS-Excel 2003 or Front Page 2003. And also when we use OWC11 for client side charting the license is required on both the server and client. Where as, when we use OWC11 for server-side charting, license is required only on the server.

How to Use OWC?

OWC is a COM component holding four ActiveX controls.

  • Spreadsheet control
  • Chartspace control
  • Pivottable control &
  • Datasource control

OWC can be used as either client-side technology by installing it in the client system or as server-side technology by installing only in the server. Coming to the server-side, the core concentration will be on programmatic usage of OWC for generating charts dynamically. Using the OWC Chartspace component, a chart can be generated in the memory of server and can be later streamlined to the client browser as gif or jpeg as a Response to an HTTP Request. So, using OWC11 at server-side only the charting functions, which are of main interest.

Coming to ASP.Net, an OWC11 Interop assembly is required that acts as an RCW (Runtime Callable Wrapper). This Interop assembly can be generated in two ways:

  1. By using the .Net Command Line Utility “Tlbimp”.

Tlbimp owc11.dll /out:Interop.owc11.dll

  1. By using the MS Visual Studio. Net. The .Net IDE creates the wrapper directly when we select the OWC11 COM Component as one of the references for our ASP.Net web application.

Now we have two steps for generating a chart.

First step involves declaring an object of owc11.Chartspace and adding a chart object to the chartspace.charts collection object. Later we can add as many data series as required to the seriescollection object of the chart object. Last but not least we can do some formatting to the Axes, Borders and Interior of the chart as well as to the chartspace and so on.

Second step involves whether saving this chart in a physical Image files like gif or directly streamlining the chart to an Image Control. Saving the chart to a gif file can be done by exporting the chartspace object to the required file at required resolution.

Where as, Streamlining requires a bit of different setting. We have to keep the whole code that generates the chart inside the code-behind of an aspx page that contains no HTML content. Where in, this aspx page can be given as an Image source to an Image control on any other page. Inside this aspx page, after generating the chart, we have to use the GetPicture Method of the Chartspace to push the chart to the Image control directly.

Thus, we can have the charts dynamically generated on the server and pushed to the client. This approach will make the coding part easier, more formatting options and faster generation of the charts.

OWC11 Charting Engine Object Model

In OWC11, the charting engine is exposed out as a Chartspace ActiveX Control. This is something similar to a chart control that comes along with visual studio.

A simplified Chartspace object model will be as follows:

Download Details

The OWC11 is a free download available in the Microsoft website at the below link.

  • <a href="http: www.microsoft.com="" downloads="" details.aspx?familyid="7287252c-402e-4f72-97a5-e0fd290d4b76&displaylang=en"">http://www.microsoft.com/downloads/details.aspx?FamilyID=7287252c-402e-4f72-97a5-e0fd290d4b76&displaylang=en

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Author is an Engineering Graduate majoring in Computer Science. He is currently working as a Programmer Analyst with Cognizant Technology Solutions and prior worked with Keane India Ltd., Offshore of Keane Inc., BOSTON, USA. His Skill Set includes C, C++, VC++, VB(.Net), ASP(.Net), C#, SQL Server, Oracle and SAS. He is currently working on .Net Platform and develops WebForms in ASP.Net.

Comments and Discussions

 
GeneralDynamic output Pin
vic_ch200028-Jul-04 16:03
vic_ch200028-Jul-04 16:03 
GeneralRe: Dynamic output Pin
ravie gopal28-Jul-04 19:24
ravie gopal28-Jul-04 19:24 
GeneralRe: Dynamic output Pin
Rohit Gupta11-Jan-05 23:16
Rohit Gupta11-Jan-05 23:16 
GeneralRe: Dynamic output Pin
ravie gopal12-Jan-05 2:49
ravie gopal12-Jan-05 2:49 
GeneralRe: Dynamic output Pin
Taha Elsayed8-May-05 2:36
Taha Elsayed8-May-05 2:36 
GeneralError Pin
Sukim3-Jul-04 1:22
Sukim3-Jul-04 1:22 
GeneralRe: Error Pin
ravie gopal6-Jul-04 23:59
ravie gopal6-Jul-04 23:59 
GeneralRe: Error Pin
SupperCMJ9-Nov-04 21:04
SupperCMJ9-Nov-04 21:04 
GeneralThank you! Pin
xiao_ys17-Jun-04 19:13
xiao_ys17-Jun-04 19:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.