问题
I am making an Excel Tool using Open XML for some data processing. In this I need to refresh my pivot tables programmatically after inserting the data by refreshing the pivot Cache. I can do this by Microsoft.Office.Interop.Excel assembly but it takes time in opening large files so I want to do this by using Open XML.
Do you have any idea that How can I do this using Open XML?
Please reply soon.
Thank you
回答1:
using SDK see the answers here: Excel "Refresh All" with OpenXML
when directly editing ooxml to fill a template xlsx:
edit pivotcache xml file: xl/pivotCache/pivotCacheDefinition*.xml
add the property-value: refreshOnLoad="1"
to node: pivotCacheDefinition
<pivotCacheDefinition
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
r:id="rId1"
refreshOnLoad="1">
来源:https://stackoverflow.com/questions/11670816/how-to-refresh-pivot-cache-of-excel-2010-using-open-xml