RamblingCookieMonster / PSExcel

A simple Excel PowerShell module

Home Page:http://ramblingcookiemonster.github.io/PSExcel-Intro/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NumberFormat not applied to cells in PivotTable

PeterGeelen opened this issue · comments

I'm using Powershell to pull datetime values in Excel and next the script generates a PivotTable for each table.
(using the dfinke/ImportExcel module).

To format cells in hh:mm:ss format, I use PSExcel module.
For the plain tables the format works fine.
But the data in the PivotTables are not formatted as requested...

Format Data Worksheet

$Sheetnames = 'Min', 'Max', 'Average', 'Errors', 'ErrorTypes'

foreach ($sheet in $Sheetnames)
{
$Worksheet = $Excel | Get-Worksheet -Name $sheet
$Worksheet | Format-Cell -StartColumn 4 -EndColumn 4 -Autofit -NumberFormat 'hh:mm:ss'
}

Format Pivot Worksheet

$Sheetnames = 'MinPivotTable', 'MaxPivotTable', 'AveragePivotTable'

foreach ($sheet in $Sheetnames)
{
$Worksheet = $Excel | Get-Worksheet -Name $sheet
$Worksheet | Format-Cell -StartColumn 2 -EndColumn 8 -Autofit -NumberFormat 'hh:mm:ss'

Any suggestion how to get this working?