Microsoft Office Interop Excel

时间:2012-04-23 07:47:17

标签: asp.net interop

我正在使用VS 2008在asp.net/C#/.net 3.5中开发Microsoft.Office.Interopt.Excel应用程序。

我正在尝试刷新数据透视表但是 以下语句不会编译。

wkSheet.PivotTables("PivotTable1").PivotCache.Refresh;

我一直得到以下2个错误。有人可以帮忙!

1.Only assignment, call, increment, decrement, and new object expressions can be used as a statement    

2.'object' does not contain a definition for 'PivotCache' and no extension method 'PivotCache' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

1 个答案:

答案 0 :(得分:0)

这些消息都很清楚,尝试类似:

PivotTable pvtTable = (PivotTable)wkSheet.PivotTables("PivotTable1");
pvtTable.RefreshTable();