mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
13 lines
762 B
PowerShell
13 lines
762 B
PowerShell
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
|
|
|
|
#Get rid of pre-exisiting sheet
|
|
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
|
|
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
|
|
Remove-Item $xlSourcefile -ErrorAction Ignore
|
|
|
|
$PivotTableDefinition = New-PivotTableDefinition -Activate -PivotTableName Points `
|
|
-PivotRows Driver, Date -PivotData @{Points = "SUM"} -GroupDateRow Date -GroupDatePart Years, Months
|
|
|
|
Import-Csv "$PSScriptRoot\First10Races.csv" |
|
|
Select-Object Race, @{n = "Date"; e = {[datetime]::ParseExact($_.date, "dd/MM/yyyy", (Get-Culture))}}, FinishPosition, Driver, GridPosition, Team, Points |
|
|
Export-Excel $xlSourcefile -Show -AutoSize -PivotTableDefinition $PivotTableDefinition |