From c4d20a9a2867f0648f793bd9efbc91f2092ce2ed Mon Sep 17 00:00:00 2001 From: MikeyBronowski Date: Wed, 1 Jul 2020 22:10:00 +0200 Subject: [PATCH] Standardise file cleanup --- Examples/Charts/NumberOfVisitors.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Examples/Charts/NumberOfVisitors.ps1 b/Examples/Charts/NumberOfVisitors.ps1 index b4c7e3f..806af8d 100644 --- a/Examples/Charts/NumberOfVisitors.ps1 +++ b/Examples/Charts/NumberOfVisitors.ps1 @@ -1,7 +1,9 @@ try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} -$xlfile = "$env:TEMP\visitors.xlsx" -Remove-Item $xlfile -ErrorAction SilentlyContinue +#Get rid of pre-exisiting sheet +$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" +Write-Verbose -Verbose -Message "Save location: $xlSourcefile" +Remove-Item $xlSourcefile -ErrorAction Ignore $data = ConvertFrom-Csv @" Week, TotalVisitors @@ -25,5 +27,5 @@ $cd = New-ExcelChartDefinition ` -NoLegend ` -ChartTrendLine Linear -$data | Export-Excel $xlfile -Show -AutoNameRange -AutoSize -TableName Visitors -ExcelChartDefinition $cd +$data | Export-Excel $xlSourcefile -Show -AutoNameRange -AutoSize -TableName Visitors -ExcelChartDefinition $cd