如何使用Open XML刷新Excel 2010的Pivot Cache

时间:2012-07-26 13:51:29

标签: c# openxml

我使用 Open XML 制作 Excel工具进行某些数据处理。在此,我需要通过刷新数据透视缓存插入数据后以编程方式刷新数据透视表。我可以通过 Microsoft.Office.Interop.Excel程序集来做到这一点,但是打开大文件需要时间,所以我想通过使用Open XML来实现这一点。

您是否知道如何使用Open XML执行此操作?

请尽快回复。

谢谢

1 个答案:

答案 0 :(得分:1)

使用SDK查看答案: Excel "Refresh All" with OpenXML

直接编辑ooxml以填充模板xlsx:
编辑pivotcache xml文件: xl / pivotCache / pivotCacheDefinition * .xml
添加属性值: refreshOnLoad =“1”
到节点: pivotCacheDefinition

<pivotCacheDefinition 
    xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" 
    xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
    r:id="rId1" 
    refreshOnLoad="1">