OWC 10 & C# ?

N

Nelson

Hi guys,

I'm developing a Web application with VS.NET 2003 (C#) and
I'm trying to use OWC 10 (Chart control) to show somw kind
of graphics but .... All documentation I've found about
programming with OWC's only mention VB as a programming
language .... anyone have developed some project or trying
with OWC 10 and C#?

Thanks.
 
C

Cooked

Thanks Alvin! You obviously have done a lot with the OWC's. However, I didn't see much specifically related to c# syntax. Can you direct me

BTW. Interesting web site. Looks like it won't be long before you have enough to write a book on OWC's yourself.
 
A

Alvin Bruney [MVP]

what exactly are you trying to do. spawning a chart from the owc is easy if
you follow this approach.



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();





The literal values are:

string strCategory = "1,2,3,4,5";
string strValue = "2,3,2,3,6";
string strSeriesName = "3D owc Bar chart";
 
C

Cooked

I think Nelson is working with Charting and I'm working with the SpreadSheet, but our goal is one in the same in that we both need syntactical help for the OWC interop assembly interface using C#. For example, I'm trying to get the Range.Find() to work and I get exceptions. Seems pretty straight forward until you actually implement it. The help files only give you the general idea because they are in VB and the syntax is different. Just yesterday for example I finally figured out that the Constants are not exposed thru the interop assemblies as parameters but you can get to them thru the base Interop assembly. They also go by slightly different names that what's in the VB help files making them fun to find sometimes

This might be out of scope for Nelson's thread here but here is my Find statement that compiles but throws a useless exception

// Delete row in OWC gri
object param1 = new object()
param1 = this.axSpreadsheet.ActiveSheet.Cells[1,1]
object param2 = new object()
param2 = OWC10.XlFindLookIn.xlValues
object param3 = new object()
param3 = OWC10.XlLookAt.xlWhole
object param4 = new object()
param4 = OWC10.XlSearchOrder.xlByRows
object param6 = new object()
param6 = true; // match cas
object param7 = new object()
param7 = true; // match byt

//can't have optional args in C# when no params array is available. (Compiler Error CS1501)..
OWC10.Range foundRngToDel = this.axSpreadsheet.ActiveSheet.UsedRange.Find(assetTypeCode,
ref param1, ref param2, ref param3, ref param4, OWC10.XlSearchDirection.xlNext,
ref param6, ref param7)

if(foundRngToDel.Rows.Count > 0

object paramShift = new object()
paramShift = OWC10.XlDeleteShiftDirection.xlShiftUp
foundRngToDel.Delete(ref paramShift)



----- Alvin Bruney [MVP] wrote: ----

what exactly are you trying to do. spawning a chart from the owc is easy if
you follow this approach



ChartSpace objCSpace = new ChartSpaceClass ()

//Add a chart

ChChart objChart = objCSpace.Charts.Add (0)

//I want a 3D bar char

objChart.Type = ChartChartTypeEnum.chChartTypeBar3D

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

objChart.SeriesCollection.Add(0)

//Give the name of the serie

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

//Give the Categorie

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



//Give The value

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

//display the char

Response.ContentType= "image/gif"

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

Response.End()





The literal values are

string strCategory = "1,2,3,4,5"
string strValue = "2,3,2,3,6"
string strSeriesName = "3D owc Bar chart"
 
L

lyndon hughey

Thank you very much Alvin. I have been looking for examples in C#


Alvin Bruney said:
what exactly are you trying to do. spawning a chart from the owc is easy if
you follow this approach.



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();





The literal values are:

string strCategory = "1,2,3,4,5";
string strValue = "2,3,2,3,6";
string strSeriesName = "3D owc Bar chart";

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Cooked said:
Thanks Alvin! You obviously have done a lot with the OWC's. However, I
didn't see much specifically related to c# syntax. Can you direct me?

BTW. Interesting web site. Looks like it won't be long before you have
enough to write a book on OWC's yourself.
 

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