Refreshing an Excel Pivot table from C#

前端 未结 3 612
旧巷少年郎
旧巷少年郎 2021-01-14 04:57

I am trying to refresh a pivot table in an Excel sheet and get the following exception:

Item method in the PivotTables class failed

Heres t

3条回答
  •  耶瑟儿~
    2021-01-14 05:33

    Assuming the indexing starts at zero you will overrun the collection with your loop.

    Try:

    for (int i = 0; i < pivotTablesCount; i++)
    

    If that doesn't work Excel probably starts indexing at 1 not at 0.

    Try:

    for (int i = 1; i <= pivotTablesCount; i++)
    

提交回复
热议问题