这是一部分自己做的代码,但是不知道怎么设置统计图的样式
public void setChartDate(String filepath,String pos,List list){
ActiveXComponent word=null;
Dispatch doc=null;
Dispatch graph=null;
try{
word = new ActiveXComponent("Word.Application");//开启
//得到word对象的处于活动状态的Document
Dispatch documents = Dispatch.get(word,"Documents").toDispatch();
//打开已经存在的word对象如果是新建一个word文件的话,需要将Open换成Add,然后去掉filepath参数即可
doc = Dispatch.call(documents, "Open",filepath).toDispatch();
//得到该对象的编辑区域
Dispatch selection = Dispatch.get(word, "Selection").toDispatch();
//设置该对象不可见
Dispatch.put(word, "Visible", new Variant(false));
//插入ole对象
Dispatch inLine =Dispatch.get(selection,"InlineShapes").toDispatch();
graph=Dispatch.call(inLine, "AddOLEObject","MSGraph.Chart.8").toDispatch();
//设置图表的高度
Dispatch.put(graph, "Height", new Variant(200.00));
//设置表的宽度
Dispatch.put(graph, "Width", new Variant(350.00));
//格式化图表
Dispatch oleFormat = Dispatch.call(graph,"OLEFormat").toDispatch();
Dispatch obj = Dispatch.call(oleFormat, "Object").toDispatch();
Dispatch dataSheet = Dispatch.get(obj, "Application").toDispatch();
Dispatch dataSheet2 = Dispatch.get(dataSheet, "dataSheet").toDispatch();
//得到该图表的数据表
//得到数据表的单元格
Dispatch cells = Dispatch.get(dataSheet2, "Cells").toDispatch();
//得到数据表的行
//Dispatch rows= Dispatch.get(cells, "Rows").toDispatch();
// System.out.println(rows);
//清空数据表行的默认数据
//Dispatch.call(rows, "Clear");
//for循环添加数据
for(int i=0;i<list.size();i++){
Object[] o=list.get(i);
for(int j=0;j<o.length;j++){
Dispatch item = Dispatch.call(cells, "Item",new Variant(i+2),new Variant(j+2)).toDispatch();
Dispatch.put(item, "value", o[i]);
}
}
if (find(selection,pos)) {
Dispatch textRange = Dispatch.get(selection, "Range")
.toDispatch();
Dispatch.call(textRange, "Paste");
}
}catch(Exception e){
e.printStackTrace();
}finally{
//关闭word文档,参数表示是否保存
Dispatch.call(doc, "Close",new Variant(true));
//退出word文档,这步和关闭一样,因为只关闭不退出,该word的进程不会结束
Dispatch.call(word, "Quit",new Variant(0));
//释放word编辑的时候引用的其他资源,比如Graph.exe进程
ComThread.Release();
doc=null;
graph=null;
word=null;
}
}
求大神帮忙解决一下,万分感谢