Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Note

The instructions on this page apply for using pivot tables with ExcelWriter 7.6 and above. If you are using ExcelWriter 7.5 or earlier please use the instructions on Templates and Pivot Tables in Older Versions

A PivotTable pivot table report is an interactive table which allows the user to have multiple views of data. By changing the view, the PivotTable pivot table report can show different summaries of the data or drill down to display more details for particular areas. ExcelWriter allows you to include PivotTables pivot tables in an ExcelWriter template file. If there are PivotTables pivot tables in the original template file, they will be preserved when the template is processed using ExcelWriter.

...

Anchor
datamarker
datamarker

...

For detailed information on data markers, see Creating Data Markers.

Anchor
scenario
scenario

Data markers and

...

pivot tables

ExcelTemplate data markers can be used to bind data to a template for use with a Pivot Table. When ExcelTemplate binds the data to the data markers, it also updates the range that the PivotTable pivot table uses as a pivot table cache. By setting the pivot tables to refresh on opening, they will automatically bring in the new values from the pivot table cache.

Anchor
howto
howto

How to Create an ExcelWriter Template with

...

pivot tables

  1. Create a template file containing data markers, each with their own column heading (see How To Use Templates). Do not create any of the PivotTables pivot tables yet.
    !Data Markers.png!
    # In Excel 2003: Use Microsoft Excel's PivotTable pivot table and PivotChart Report Wizard to create a PivotTable pivot table referencing the range of cells containing the column headings and data markers.
    !PivotTableWizardpivot tableWizard.png!
    *In Excel 2007 or above:* Use the Ribbon controls (in Excel 2007 and beyond) to create a PivotTable pivot table referencing the range of cells containing the column headings and data markers.
    !PivotTableRibbonpivot tableRibbon.png!
    # Specify the initial layout and field formatting for the PivotTablepivot table. Place the PivotTable pivot table in any worksheet you desire. (See the Excel documentation for more details about creating your PivotTablepivot table.)
    # In Excel 2003: Before clicking "Finish" in the Wizard, click the "Options" button and make sure that "Refresh on open" is checked.
    !RefreshOnOpen2003.png!
    *In Excel 2007 or above:* After creating the Pivot Table, right-click on the table and select "PivotTable pivot table Options". Click on the Data tab and make sure that "Refresh data on opening the file" is checked. Also, make sure to select None from the Number of items to retain per field
    !PT_DataOptions_New.png!
    # In your newly created PivotTablepivot table, you will now see the data markers. Data markers in the pivot table will be ignored by ExcelWriter, which will instead update the data source.
    !Finished Table.png!
    # Repeat steps 2 through 5 for every PivotTable pivot table you wish to create. Finish creating your template file and save it in the location on your server which will be accessed by your ExcelWriter script.
    Scrollbar