OWC + ASP.Net

B

Bob

I am working on a project where I need to use Microsoft Office Web
Components in an ASP.Net page using VB. I want to start out simple by
creating a page that graphs data from a hard coded array. Can anyone
provide me with assistance in doing this? Thus far I have been
unsuccessful in getting this to work. Thanks in advance.
 
D

David M. Andersen

Bob said:
I am working on a project where I need to use Microsoft Office Web
Components in an ASP.Net page using VB. I want to start out simple by
creating a page that graphs data from a hard coded array. Can anyone
provide me with assistance in doing this? Thus far I have been
unsuccessful in getting this to work. Thanks in advance.

I usually just output raw XML to the client manually. I never actually
use OWC on the server side for what I do. If you want the XML data for
a given component, just get the XMLData property and output it to
another browser window and view its source.

See:
http://www.microsoft.com/downloads/...52-3547-420a-a412-00a2662442d9&DisplayLang=en
http://www.microsoft.com/office/xml/default.mspx
 
A

Alvin Bruney [MVP]

string strSeriesName = "Programming OWC with .NET";

string strCategory = "1,2,3,4";

string strValue = "5,6,7,8";



ChartSpace objCSpace = new ChartSpaceClass ();

//Add a chart.

ChChart objChart = objCSpace.Charts.Add (0);

//I want a 3D bar chart

objChart.Type = ChartChartTypeEnum.chChartTypeBar3D;

//Add a series to the chart's series collection

objChart.SeriesCollection.Add(0);

//Give the name of the series

objChart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimSeriesNames,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);

//Give the Categories

objChart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, strCategory);



//Give The values

objChart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimValues,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, strValue);

//display the chart

Response.ContentType= "image/gif";

Response.BinaryWrite((byte[])objCSpace.GetPicture("gif",400,400));

Response.End();
 
B

Bob

Alvin,

Thanks for the code. I had to tweak it a little to get it to work as
VB.Net, but that wasn't too hard. After looking at the code I was
wondering two things...

1. Can you no longer drop the OWC component onto a web page in .Net
and use it that way? If you can, how would you use it? I tried
referencing it, but was having trouble accessing it from my code
behind since the OWC is a COM object.

2. If you have a page with a label on it for example, do you have to
put the graph in an IFrame or some sort of frame in order to keep it
from keeping the other parts of the page from showing?

Thanks again for the help.
 
A

Alvin Bruney [MVP]

Typically, you can use a place holder control and write the chart into the
place holder.

The OWC is really a client-side technology. It can be automated only from
the client. With that said, the average .net programmer should be aware that
script can be streamed out to the client thru facilities like the intrinsic
Response object, registerstartupscript etc. With that approach, it is
entirely possible to automate the client-side owc from the code-behind by
streaming out bits of script as needed.

If you do not use codebehind, you can write your script out inside the html
page similar to html/asp programming.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top