views:

34

answers:

1

Hello,

I have an excel 2007 file (OpenXML format) with a connection to an xml file. This connection generates an excel table and pivot charts are using this table.

I am trying to find a way with OpenXML SDK v2 to do the same as the "Refresh All" button in Excel. So that I could automatically update my file as soon as a new xml file is provided. So I would need to firstly refresh the table thanks, then refresh pivot tables.

I found absolutely nothing with google during hours. I hope anyone will be able to give me good indications.

Thank you.

+1  A: 

I think the only way you can do this is following this type of method..

  1. Save Open XML workbook back to a xlsx file.
  2. Load the workbook using the Excel object model.
  3. Call either

    ThisWorkbook.PivotCaches(yourIndex).Refresh

or

ThisWorkbook.RefreshAll 

although I was pretty sure RefreshAll would also work.
4. Use the object model to Save the workbook and close it.
5. Reopen for use with xml namespaces.

Anonymous Type
This is a method from the COM excel class. It is unavailable in the OpenXML classes since it is to manipulate the XML.Finally, I don't think it is possible.
Julio Guerra
Refresh All should refresh pivot tables. I'll edit my answer in line with your comment above.
Anonymous Type
Thanks for you time but I finally found another solution for my problem: I set the option "refresh when opening the file" of all my pivot tables. Then I simply export data to a main table so that the excel file automatically changes.
Julio Guerra
yep you can definately set pivot tables to refresh automatically, thats just a configuration change in Excel. I assumed you were looking for a means of manual refresh due to performance isuses, sorry my bad for making assumption. You should post your answer and accept it for others to refer to.
Anonymous Type