Click here to Skip to main content
Click here to Skip to main content
Go to top

ASP.NET Server-Side Charting with OWC11

, 9 Jun 2004
Rate this:
Please Sign up or sign in to vote.
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.

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

Share

About the Author

ravie gopal
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

 
GeneralSpreadsheetGear for .NET as OWC Replacement PinmemberJoe Erickson18-Oct-08 9:16 
GeneralInsert an image with owc 11 in asp.net 2.0 c# PinmemberMember 396244523-Jun-08 10:12 
Generalusing Pivot table in asp.net PinmemberMember 421342510-Jun-08 21:30 
GeneralError in .net 2.0 Pinmembersheva1019-Aug-07 17:58 
QuestionImageUrl never changes Pinmemberlianaent27-Jul-07 7:52 
AnswerRe: ImageUrl never changes Pinmemberlianaent27-Jul-07 8:34 
AnswerRe: ImageUrl never changes PinmemberJason Gilley14-Jan-09 17:01 
QuestionAdjust Scale at runtime... [modified] Pinmemberwylau11-Dec-06 16:42 
QuestionASP.NET 2.0 PinmemberSethuraman Subramanian19-Sep-06 11:47 
AnswerRe: ASP.NET 2.0 Pinmemberravie gopal1-Nov-06 13:22 
GeneralUpdate Sql server table when IE Closes in asp.net application PinmemberNidheesh21-Aug-06 1:14 
QuestionLoading from excel file using OWC11, C# and asp.net PinmemberSherrrrrry8-Aug-06 20:11 
QuestionHow To Export a Chart to Word in asp.net Pinmemberworldoferic23-May-06 3:38 
General2-dimensional categories Pinmemberpiv12416-May-05 9:32 
Generalbig problem(Memory) PinmemberTaha Zayed8-May-05 2:44 
GeneralRe: big problem(Memory) Pinmemberravie gopal1-Nov-06 13:31 
GeneralChart with DataSet PinmemberA_JR12-Apr-05 5:02 
Generalowc 11 license Pinsusstomaney30-Dec-04 17:47 
GeneralRe: owc 11 license PinmemberRossDonald11-Mar-05 19:25 
GeneralAccess Denied PinmemberGruuberusbop5-Nov-04 4:14 
GeneralRe: Access Denied Pinmemberravie gopal5-Nov-04 22:54 
GeneralRe: Access Denied Pinmemberss173b22-Jan-05 18:38 
GeneralRe: Access Denied Pinmemberravie gopal23-Jan-05 17:55 
GeneralRe: Access Denied PinmemberTaha Zayed8-May-05 2:29 
GeneralRe: Access Denied PinmemberMetsadah19-Sep-06 3:04 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 10 Jun 2004
Article Copyright 2004 by ravie gopal
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid