Revert "Improved ' Get-ExcelSheetInfo '"

This reverts commit d830278cbc.
This commit is contained in:
DarkLite1
2017-02-14 08:28:00 +01:00
parent d830278cbc
commit ecd2fbbc1f

View File

@@ -9,9 +9,6 @@ Function Get-ExcelSheetInfo {
.PARAMETER Path
Specifies the path to the Excel file. This parameter is required.
.PARAMETER Type
Specifies which information to get, the one from the workbook or the one from the sheets.
.EXAMPLE
Get-ExcelSheetInfo .\Test.xlsx
@@ -21,34 +18,22 @@ Function Get-ExcelSheetInfo {
.LINK
https://github.com/dfinke/ImportExcel
#>
[CmdletBinding()]
Param (
param(
[Alias("FullName")]
[Parameter(ValueFromPipelineByPropertyName, ValueFromPipeline, Mandatory)]
[String]$Path,
[ValidateSet('Sheets', 'Workbook')]
[String]$Type = 'Workbook'
[Parameter(ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true, Mandatory=$true)]
$Path
)
Process {
Try {
process {
$Path = (Resolve-Path $Path).ProviderPath
Write-Debug "target excel file $Path"
write-debug "target excel file $Path"
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path,"Open","Read","ReadWrite"
$xl = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream
$workbook = $xl.Workbook
Switch ($Type) {
'Workbook' {
if ($workbook) {
$workbook.Properties
}
}
'Sheets' {
if ($workbook -and $workbook.Worksheets) {
if($workbook -and $workbook.Worksheets) {
$workbook.Worksheets |
Select-Object -Property name,index,hidden,@{
Label = "Path"
@@ -56,13 +41,4 @@ Function Get-ExcelSheetInfo {
}
}
}
Default {
Write-Error 'Unrecogrnized type'
}
}
}
Catch {
throw "Failed retrieving Excel sheet information for '$Path': $_"
}
}
}