mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added Filter, Freeze and Bold first row
This commit is contained in:
@@ -82,7 +82,7 @@ function Export-ExcelSheet {
|
||||
|
||||
Import-Excel $Path -Sheet $($sheet.Name) | Export-Csv @params -Encoding $Encoding
|
||||
}
|
||||
|
||||
|
||||
$xl.Dispose()
|
||||
}
|
||||
|
||||
@@ -119,7 +119,10 @@ function Export-Excel {
|
||||
[Switch]$IncludePivotChart,
|
||||
[Switch]$AutoSize,
|
||||
[Switch]$Show,
|
||||
[Switch]$NoClobber
|
||||
[Switch]$NoClobber,
|
||||
[Switch]$FreezeTopRow,
|
||||
[Switch]$AutoFilter,
|
||||
[Switch]$BoldFirstRow
|
||||
)
|
||||
|
||||
Begin {
|
||||
@@ -230,9 +233,25 @@ function Export-Excel {
|
||||
}
|
||||
}
|
||||
|
||||
if($AutoSize) { $ws.Cells.AutoFitColumns() }
|
||||
if($Password) { $ws.Protection.SetPassword($Password) }
|
||||
|
||||
if($AutoFilter) {
|
||||
$startAddress=$ws.Dimension.Start.Address
|
||||
$range="{0}:{1}" -f $startAddress, $ws.Dimension.End.Address
|
||||
$ws.Cells[$range].AutoFilter=$true
|
||||
}
|
||||
|
||||
if($FreezeTopRow) {
|
||||
$ws.View.FreezePanes(2,1)
|
||||
}
|
||||
|
||||
if($BoldFirstRow) {
|
||||
$range=$ws.Dimension.Address -replace $ws.Dimension.Rows, "1"
|
||||
$ws.Cells[$range].Style.Font.Bold=$true
|
||||
}
|
||||
|
||||
if($AutoSize) { $ws.Cells.AutoFitColumns() }
|
||||
|
||||
$pkg.Save()
|
||||
$pkg.Dispose()
|
||||
|
||||
@@ -291,7 +310,7 @@ function ConvertFrom-ExcelSheet {
|
||||
|
||||
Import-Excel $Path -Sheet $($sheet.Name) | Export-Csv @params -Encoding $Encoding
|
||||
}
|
||||
|
||||
|
||||
$xl.Dispose()
|
||||
}
|
||||
|
||||
|
||||
14
README.md
14
README.md
@@ -19,6 +19,20 @@ Know Issues
|
||||
|
||||
What's new
|
||||
-
|
||||
#### 5/17/2015
|
||||
* Added three parameters:
|
||||
* FreezeTopRow - Freezes the first row of the data
|
||||
* AutoFilter - Enables filtering for the data in the sheet
|
||||
* BoldFirstRow - Bolds the first row of data, the column headers
|
||||
|
||||
Example
|
||||
|
||||
Get-CimInstance win32_service |
|
||||
select state, accept*, start*, caption |
|
||||
Export-Excel test.xlsx -Show -BoldFirstRow -AutoFilter -FreezeTopRow -AutoSize
|
||||
|
||||

|
||||
|
||||
|
||||
#### 5/4/2015
|
||||
* Published to PowerShell Gallery. In PowerShell v5 use `Find-Module importexcel` then `Find-Module importexcel | Install-Module`
|
||||
|
||||
Reference in New Issue
Block a user