PC Review


Reply
Thread Tools Rate Thread

C# 2005 Excel access to Axis (xlSecondary)

 
 
thomas.ziolko@web.de
Guest
Posts: n/a
 
      26th May 2008
hi,

i don't get access to the secondary axis by using the excel interop in
c#

at the following code i get an error "Exception from HRESULT:
0x800A03EC" (-2146827284)


//Add a Chart for the selected data.
oChart = (Excel.Chart)wb.Charts.Add(Missing.Value, Missing.Value,
Missing.Value, Missing.Value);

oChart.ChartType = XlChartType.xlColumnStacked;
oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlPrimary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlSecondary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlSecondary, true);

Excel.Axis axCategory2 =
(Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlSecondary);
axCategory2.CategoryType = XlCategoryType.xlAutomaticScale;
axCategory2.Border.Weight = 1;

Excel.Axis axCategory =
(Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlPrimary);
axCategory.Border.LineStyle = Excel.XlLineStyle.xlDot;
axCategory.TickLabels.Orientation =
XlTickLabelOrientation.xlTickLabelOrientationHorizontal;
axCategory.TickLabels.Font.Size = 8;

oResizeRange = oWS.get_Range("B1:B" + anzDSReal.ToString(),
Missing.Value);
oChart.SetSourceData(oResizeRange, Excel.XlRowCol.xlColumns);
oChart.HasLegend = false;
....

can anyone help?

Thx
Thomas
 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      27th May 2008
I can't say anything intelligent about the C# piece of your problem. For
plain old Excel/VBA I'd suggest checking that (a) you had two or more series
in the chart and that at least one series was in the xlSecondary AxisGroup,
and (b) the secondary axis doesn't coincide with a primary axis, because
sometimes if both axes are located along the same edge of the chart, one
(usually primary) prevents access to the other (usually secondary). The
position of an axis is set by the CrossesAt and CrossesAtMaximum properties
of the orthogonal axis (i.e., secondary value axis position controlled by
properties of secondary category axis), which also must exist.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


<(E-Mail Removed)> wrote in message
news:fea9cf88-b260-4ed6-8a3a-(E-Mail Removed)...
> hi,
>
> i don't get access to the secondary axis by using the excel interop in
> c#
>
> at the following code i get an error "Exception from HRESULT:
> 0x800A03EC" (-2146827284)
>
>
> //Add a Chart for the selected data.
> oChart = (Excel.Chart)wb.Charts.Add(Missing.Value, Missing.Value,
> Missing.Value, Missing.Value);
>
> oChart.ChartType = XlChartType.xlColumnStacked;
> oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
> Excel.XlAxisGroup.xlPrimary, true);
> oChart.set_HasAxis(Excel.XlAxisType.xlValue,
> Excel.XlAxisGroup.xlPrimary, true);
> oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
> Excel.XlAxisGroup.xlSecondary, true);
> oChart.set_HasAxis(Excel.XlAxisType.xlValue,
> Excel.XlAxisGroup.xlSecondary, true);
>
> Excel.Axis axCategory2 =
> (Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategory,
> Excel.XlAxisGroup.xlSecondary);
> axCategory2.CategoryType = XlCategoryType.xlAutomaticScale;
> axCategory2.Border.Weight = 1;
>
> Excel.Axis axCategory =
> (Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategory,
> Excel.XlAxisGroup.xlPrimary);
> axCategory.Border.LineStyle = Excel.XlLineStyle.xlDot;
> axCategory.TickLabels.Orientation =
> XlTickLabelOrientation.xlTickLabelOrientationHorizontal;
> axCategory.TickLabels.Font.Size = 8;
>
> oResizeRange = oWS.get_Range("B1:B" + anzDSReal.ToString(),
> Missing.Value);
> oChart.SetSourceData(oResizeRange, Excel.XlRowCol.xlColumns);
> oChart.HasLegend = false;
> ...
>
> can anyone help?
>
> Thx
> Thomas



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to Excel Automation : problem with Category X Axis Gustav Microsoft Access VBA Modules 2 3rd Sep 2007 07:37 PM
Excel 2003: Mapping rows (x-axis) vs multiple columns (y-axis) =?Utf-8?B?VG9t?= Microsoft Excel Misc 1 29th May 2007 01:03 PM
.Net 2005 Forms ReportViewer Chart y axis values bugs =?Utf-8?B?UHVyb210ZWM=?= Microsoft Dot NET Framework 0 4th Apr 2006 09:19 PM
can I make the vertical axis the category axis in Excel line graph =?Utf-8?B?cG93ZXIx?= Microsoft Excel Charting 1 20th Mar 2006 08:45 PM
How do I make the Y axis in an excel chart the category axis? =?Utf-8?B?bWVnbmFkb29kbGU=?= Microsoft Excel Charting 2 29th Mar 2005 09:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:47 PM.