object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
object remarkOverTable = "OverTable";
//Start Word and create a new document.
Microsoft.Office.Interop.Word._Application oWord;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = true ;
object Template = "Report.dot";
oDoc = oWord.Documents.Add(ref Template, ref oMissing,
ref oMissing, ref oMissing);
//得到书签
Microsoft.Office.Interop.Word.Range TestRemark = oDoc.Bookmarks.get_Item(ref remarkOverTable).Range;
TestRemark.InlineShapes[0].OLEFormat.Open();// 打开OLE对像,注意这一步一定要有
Microsoft.Office.Interop.Graph.Chart _testChart =
(Microsoft.Office.Interop.Graph.Chart)(TestRemark.InlineShapes[0].OLEFormat.Object);
Microsoft.Office.Interop.Graph.Application _testApp =
_testChart.Application;
object[] Values = new object[] { "91%", "92%", "93%", "94%", "95%" };
for (int i = 0, j = System.Convert.ToInt32('A'); i < Values.Length; i++)
{
//这里的行列式为循环下来填写的是A2,B2,C2,D2.... OK?
_testChart.Application.DataSheet.Cells.set_Item(2, System.Convert.ToString(
(char)( j+ i)),
Values[0]);
}
_testApp.Quit();