PowerShell Out-ExcelPivotTable – Quickly Create Pivot Tables in Microsoft Excel

by Doug Finke on June 24, 2009

in Excel, Pivot Tables, PowerShell

The Data – People.csv

image

Use Import-Csv and type the data with Select

image 

Create the Excel Pivot Table

$people | .\Out-ExcelPivotTable

 

image

The easiest way to get a Pivot Table.

Out-ExcelPivotTable inspects the piped data, sets up the numeric properties as data fields and string properties as row fields (nested).

 

 

$people | .\Out-ExcelPivotTable name dept salary

 

image

Same data.

You control what goes in the different pivot fields. Row (name), Column (dept) and Data (salary).

 

 

 

$people | .\Out-ExcelPivotTable -values YearsEmployeed

 

image

You control the pivot data field with the –values parameter letting  Out-ExcelPivotTable do the rest.

Name is nested in Department.

 

 

 

 

ToDo

  • Set up Out-ExcelPivotTable parameters to take arrays
  • Formatting of value fields
  • Naming of Row and Column Labels
  • Enable Types of aggregates for Value field
  • Improve data layout performance

I have only tried this on the latest version of Excel.

Download It

{ 2 comments… read them below or add one }

1 Grant 06.28.09 at 8:19 am

Pretty Schweet !!!

2 Andy 07.23.09 at 10:13 pm

Another gem !

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>