c# - Office interop Chart autoscaling -
for generate 1 graph in word interop document use method below:
public static void addsimplechart(document worddoc, microsoft.office.interop.word.application wordapp, string[,] data) { object omissing = system.reflection.missing.value; microsoft.office.interop.word.inlineshape oshape; object oclasstype = "msgraph.chart.8"; object oendofdoc4 = "\\endofdoc"; microsoft.office.interop.word.range wrdrng = worddoc.bookmarks.get_item(ref oendofdoc4).range; oshape = wrdrng.inlineshapes.addoleobject(ref oclasstype, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing); //demonstrate use of late bound ochart , ochartapp objects //manipulate chart object msgraph. object ochart; object ochartapp; ochart = oshape.oleformat.object; ochartapp = ochart.gettype().invokemember("application", bindingflags.getproperty, null, ochart, null); //change chart type line. object[] parameters = new object[1]; parameters[0] = 1; //xlline = 4 ochart.gettype().invokemember("charttype", bindingflags.setproperty, null, ochart, parameters); microsoft.office.interop.graph.chart objchart = (microsoft.office.interop.graph.chart)oshape.oleformat.object; objchart.charttype = microsoft.office.interop.graph.xlcharttype.xllinemarkers; datasheet datasheet; datasheet = objchart.application.datasheet; int rownum = data.getlength(0); int columnnum = data.getlength(1); (int = 1; <= rownum; i++) (int j = 1; j <= columnnum; j++) { datasheet.cells[i, j] = data[i - 1, j - 1]; } objchart.application.update(); ochartapp.gettype().invokemember("update", bindingflags.invokemethod, null, ochartapp, null); ochartapp.gettype().invokemember("quit", bindingflags.invokemethod, null, ochartapp, null); oshape.width = wordapp.inchestopoints(6.25f); oshape.height = wordapp.inchestopoints(3.57f); wrdrng = worddoc.bookmarks.get_item(ref oendofdoc4).range; wrdrng.insertparagraphafter(); }
but rendered graph small.
anyone know how set autoscaling option in method.
when set property: objchart.autoscaling = true exception.
many help.
Comments
Post a Comment