mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-15 07:43:23 +00:00
Add extension test back in
This commit is contained in:
@@ -348,6 +348,13 @@ function Import-Excel {
|
|||||||
process {
|
process {
|
||||||
if ($path) {
|
if ($path) {
|
||||||
|
|
||||||
|
if (!$firstTimeThru) {
|
||||||
|
# '.xls$|.xlsx$|.xlsm$'
|
||||||
|
$extension = [System.IO.Path]::GetExtension($Path)
|
||||||
|
if ($extension -notmatch '.xlsx$|.xlsm$') {
|
||||||
|
throw "Import-Excel does not support reading this extension type $($extension)"
|
||||||
|
}
|
||||||
|
|
||||||
# $Path = (Resolve-Path $Path).ProviderPath
|
# $Path = (Resolve-Path $Path).ProviderPath
|
||||||
$resolvedPath = (Resolve-Path $Path -ErrorAction SilentlyContinue)
|
$resolvedPath = (Resolve-Path $Path -ErrorAction SilentlyContinue)
|
||||||
if ($resolvedPath) {
|
if ($resolvedPath) {
|
||||||
@@ -356,6 +363,8 @@ function Import-Excel {
|
|||||||
else {
|
else {
|
||||||
throw "'$($Path)' file not found"
|
throw "'$($Path)' file not found"
|
||||||
}
|
}
|
||||||
|
$firstTimeThru = $true
|
||||||
|
}
|
||||||
|
|
||||||
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path, 'Open', 'Read', 'ReadWrite'
|
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path, 'Open', 'Read', 'ReadWrite'
|
||||||
if ($Password) { $ExcelPackage = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream , $Password }
|
if ($Password) { $ExcelPackage = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream , $Password }
|
||||||
|
|||||||
Reference in New Issue
Block a user