我.net中也遇到了相同的问题:你可以先看一下下面代码,应该大部分你能用到,只是chart属性可能有点问题,之前尝试成功过,但是由于我不小心删除了一些系统文件里的内容,就有些运行不起来了
我是先循环的word中的shape
foreach (Microsoft.Office.Interop.Word.Shape shape in docFile.Shapes)
{
if(shape.Name=="Chart_图表")
{
shape.Chart.ChartData.Activate();
Microsoft.Office.Interop.Excel.Workbook wb = (Microsoft.Office.Interop.Excel.Workbook)shape.Chart.ChartData.Workbook;
Microsoft.Office.Interop.Excel.Worksheet wSh = (Microsoft.Office.Interop.Excel.Worksheet)wb.Worksheets[1];
//然后添加新数据
for (int r = 0; r < tempdt.Rows.Count; r++)
{
for (int k = 0; k < tempdt.Columns.Count; k++)
{
Microsoft.Office.Interop.Excel.Range Rng1 = wSh.Cells[r + 2, k + 1] as Microsoft.Office.Interop.Excel.Range;
Rng1.Value = tempdt.Rows[r][k];
}
}
wb.Application.ScreenUpdating = true;
wb.Close(Type.Missing, Type.Missing, Type.Missing);
chart.Refresh();
shape.Chart.Refresh();
}
}
我的业务和你一样,请问您最后怎么解决的?
BUZHIDAO