mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
@joshooaj added throw if not on Windows, pls review
This commit is contained in:
@@ -75,6 +75,10 @@ function Add-ExcelImage {
|
|||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
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
|
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
|
understand how row and column sizing works in Excel and what the
|
||||||
|
|||||||
@@ -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
|
Add-Type -AssemblyName System.Drawing
|
||||||
|
|
||||||
. $PSScriptRoot\Add-ExcelImage.ps1
|
. $PSScriptRoot\Add-ExcelImage.ps1
|
||||||
@@ -24,7 +28,8 @@ try {
|
|||||||
$image = [System.Drawing.Image]::FromFile($octocat)
|
$image = [System.Drawing.Image]::FromFile($octocat)
|
||||||
$xlpkg = $data | Export-Excel -Path $path -PassThru
|
$xlpkg = $data | Export-Excel -Path $path -PassThru
|
||||||
$xlpkg.Sheet1 | Add-ExcelImage -Image $image -Row 4 -Column 6 -ResizeCell
|
$xlpkg.Sheet1 | Add-ExcelImage -Image $image -Row 4 -Column 6 -ResizeCell
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
if ($image) {
|
if ($image) {
|
||||||
$image.Dispose()
|
$image.Dispose()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user