@joshooaj added throw if not on Windows, pls review

This commit is contained in:
dfinke
2022-02-03 18:43:15 -05:00
parent f33215382a
commit 5ab6a9116d
2 changed files with 10 additions and 1 deletions

View File

@@ -75,6 +75,10 @@ function Add-ExcelImage {
)
begin {
if ($IsWindows -eq $false) {
throw "This only works on Windows and won't run on $([environment]::OSVersion)"
}
<#
These ratios work on my machine but it feels fragile. Need to better
understand how row and column sizing works in Excel and what the

View File

@@ -1,3 +1,7 @@
if ($IsWindows -eq $false) {
throw "This only works on Windows and won't run on $([environment]::OSVersion)"
}
Add-Type -AssemblyName System.Drawing
. $PSScriptRoot\Add-ExcelImage.ps1
@@ -24,7 +28,8 @@ try {
$image = [System.Drawing.Image]::FromFile($octocat)
$xlpkg = $data | Export-Excel -Path $path -PassThru
$xlpkg.Sheet1 | Add-ExcelImage -Image $image -Row 4 -Column 6 -ResizeCell
} finally {
}
finally {
if ($image) {
$image.Dispose()
}