mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-15 15:53:32 +00:00
28 lines
814 B
PowerShell
28 lines
814 B
PowerShell
Function Get-ExcelWorkbookInfo {
|
|
[CmdletBinding()]
|
|
Param (
|
|
[Alias('FullName')]
|
|
[Parameter(ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true, Mandatory=$true)]
|
|
[String]$Path
|
|
)
|
|
|
|
Process {
|
|
Try {
|
|
$Path = (Resolve-Path $Path).ProviderPath
|
|
|
|
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path,'Open','Read','ReadWrite'
|
|
$xl = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream
|
|
$workbook = $xl.Workbook
|
|
$workbook.Properties
|
|
|
|
$stream.Close()
|
|
$stream.Dispose()
|
|
$xl.Dispose()
|
|
$xl = $null
|
|
}
|
|
Catch {
|
|
throw "Failed retrieving Excel workbook information for '$Path': $_"
|
|
}
|
|
}
|
|
}
|