How to name axis in excel using C#? -


this how create chart:

excel.chartobjects xlchartsq = (excel.chartobjects)xlworksheet.chartobjects(type.missing); excel.chartobject mychartq = (excel.chartobject)xlchartsq.add(10, 1000, 175, 310); excel.chart chartpageq = mychartq.chart; mychartq.select(); 

and have succesfully named primary axis way, have used mdsn`s code:

excel.axis axis = mychartq.chart.axes( excel.xlaxistype.xlvalue, excel.xlaxisgroup.xlprimary);  axis.hastitle = true; axis.axistitle.text = "axis`s name"; 

it works should, tried use such method name secondary axis, failed:

excel.axis axisq = mychartq.chart.axes( excel.xlaxistype.xlvalue, excel.xlaxisgroup.xlsecondary);  axisq.hastitle = true;  axisq.axistitle.text = "another axis`s name"; 

it compiled without errors, unfortunately after calling code got such error: unexpected exception "system.runtime.interopservices.comexception", , hresult e_fail error returned.

what doing wrong? suggestions?

upd1: before naming create series, but, honestly, can't figure out how can associated secondary axis.

for (int = 0; < current_excel_position; i++ ) {  excel.series series1 = seriescollection.newseries();  series1.xvalues = xlworksheet.get_range("a" + convert.tostring(92 + i), "b" +     convert.tostring(92 + i)); ;  series1.values = xlworksheet.get_range("c" + convert.tostring(92 + i), "d" + convert.tostring(92 + i)); } 

there has @ least 1 series on secondary axis. if data on primary axis cannot show / edit secondary axis.

do have series on secondary axis? if not problem.

edit: how can set value (y axis in case) , category (x axis in case):

excel.axis axisq = mychartq.chart.axes(excel.xlaxistype.xlvalue,                excel.xlaxisgroup.xlprimary); axisq.hastitle = true; axisq.axistitle.text = "value axis name";  axisq = mychartq.chart.axes(excel.xlaxistype.xlcategory,                 excel.xlaxisgroup.xlprimary); axisq.hastitle = true; axisq.axistitle.text = "category axis name"; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -