Click here to Skip to main content
11,576,977 members (51,515 online)
Click here to Skip to main content

ASP.NET Server-Side Charting with OWC11

, 9 Jun 2004 230K 14.8K 51
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.

You may also be interested in...

Comments and Discussions

 
GeneralSpreadsheetGear for .NET as OWC Replacement Pin
Joe Erickson18-Oct-08 9:16
memberJoe Erickson18-Oct-08 9:16 
GeneralInsert an image with owc 11 in asp.net 2.0 c# Pin
Member 396244523-Jun-08 10:12
memberMember 396244523-Jun-08 10:12 
Generalusing Pivot table in asp.net Pin
Member 421342510-Jun-08 21:30
memberMember 421342510-Jun-08 21:30 
GeneralError in .net 2.0 Pin
sheva1019-Aug-07 17:58
membersheva1019-Aug-07 17:58 
When i build it in VS 2005 it shows this message !

XML Parsing Error: not well-formed
Location: http://localhost/WebOWC11/WebForm1.aspx
Line Number 1, Column 2:<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebGraphApp_OWC11_Sample.WebForm1" smartNavigation="True"%>
-^

OMG | :OMG:
QuestionImageUrl never changes Pin
lianaent27-Jul-07 7:52
memberlianaent27-Jul-07 7:52 
AnswerRe: ImageUrl never changes Pin
lianaent27-Jul-07 8:34
memberlianaent27-Jul-07 8:34 
AnswerRe: ImageUrl never changes Pin
Jason Gilley14-Jan-09 17:01
memberJason Gilley14-Jan-09 17:01 
QuestionAdjust Scale at runtime... [modified] Pin
wylau11-Dec-06 16:42
memberwylau11-Dec-06 16:42 
QuestionASP.NET 2.0 Pin
Sethuraman Subramanian19-Sep-06 11:47
memberSethuraman Subramanian19-Sep-06 11:47 
AnswerRe: ASP.NET 2.0 Pin
ravie gopal1-Nov-06 13:22
memberravie gopal1-Nov-06 13:22 
GeneralUpdate Sql server table when IE Closes in asp.net application Pin
Nidheesh21-Aug-06 1:14
memberNidheesh21-Aug-06 1:14 
QuestionLoading from excel file using OWC11, C# and asp.net Pin
Sherrrrrry8-Aug-06 20:11
memberSherrrrrry8-Aug-06 20:11 
QuestionHow To Export a Chart to Word in asp.net Pin
worldoferic23-May-06 3:38
memberworldoferic23-May-06 3:38 
General2-dimensional categories Pin
piv12416-May-05 9:32
memberpiv12416-May-05 9:32 
Generalbig problem(Memory) Pin
Taha Zayed8-May-05 2:44
memberTaha Zayed8-May-05 2:44 
GeneralRe: big problem(Memory) Pin
ravie gopal1-Nov-06 13:31
memberravie gopal1-Nov-06 13:31 
GeneralChart with DataSet Pin
A_JR12-Apr-05 5:02
memberA_JR12-Apr-05 5:02 
Generalowc 11 license Pin
tomaney30-Dec-04 17:47
susstomaney30-Dec-04 17:47 
GeneralRe: owc 11 license Pin
RossDonald11-Mar-05 19:25
memberRossDonald11-Mar-05 19:25 
GeneralAccess Denied Pin
Gruuberusbop5-Nov-04 4:14
memberGruuberusbop5-Nov-04 4:14 
GeneralRe: Access Denied Pin
ravie gopal5-Nov-04 22:54
memberravie gopal5-Nov-04 22:54 
GeneralRe: Access Denied Pin
ss173b22-Jan-05 18:38
memberss173b22-Jan-05 18:38 
GeneralRe: Access Denied Pin
ravie gopal23-Jan-05 17:55
memberravie gopal23-Jan-05 17:55 
GeneralRe: Access Denied Pin
Taha Zayed8-May-05 2:29
memberTaha Zayed8-May-05 2:29 
GeneralRe: Access Denied Pin
Metsadah19-Sep-06 3:04
memberMetsadah19-Sep-06 3:04 
GeneralDynamic output Pin
vic_ch200028-Jul-04 16:03
membervic_ch200028-Jul-04 16:03 
GeneralRe: Dynamic output Pin
ravie gopal28-Jul-04 19:24
memberravie gopal28-Jul-04 19:24 
GeneralRe: Dynamic output Pin
Rohit Gupta11-Jan-05 23:16
sussRohit Gupta11-Jan-05 23:16 
GeneralRe: Dynamic output Pin
ravie gopal12-Jan-05 2:49
memberravie gopal12-Jan-05 2:49 
GeneralRe: Dynamic output Pin
Taha Zayed8-May-05 2:36
memberTaha Zayed8-May-05 2:36 
GeneralError Pin
Sukim3-Jul-04 1:22
sussSukim3-Jul-04 1:22 
GeneralRe: Error Pin
ravie gopal6-Jul-04 23:59
memberravie gopal6-Jul-04 23:59 
GeneralRe: Error Pin
SupperCMJ9-Nov-04 21:04
memberSupperCMJ9-Nov-04 21:04 
GeneralThank you! Pin
xiao_ys17-Jun-04 19:13
memberxiao_ys17-Jun-04 19:13 

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 | Terms of Use | Mobile
Web03 | 2.8.150603.1 | Last Updated 10 Jun 2004
Article Copyright 2004 by ravie gopal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid