mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
28 lines
853 B
PowerShell
28 lines
853 B
PowerShell
function Get-ExcelSheetInfo {
|
|
[CmdletBinding()]
|
|
param(
|
|
[Alias('FullName')]
|
|
[Parameter(ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true, Mandatory=$true)]
|
|
$Path
|
|
)
|
|
process {
|
|
$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
|
|
|
|
if ($workbook -and $workbook.Worksheets) {
|
|
$workbook.Worksheets |
|
|
Select-Object -Property name,index,hidden,@{
|
|
Label = 'Path'
|
|
Expression = {$Path}
|
|
}
|
|
}
|
|
|
|
$stream.Close()
|
|
$stream.Dispose()
|
|
$xl.Dispose()
|
|
$xl = $null
|
|
}
|
|
} |