mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-13 06:43:17 +00:00
Export-Excel can now make a table or a named range.
This commit is contained in:
@@ -147,7 +147,8 @@ function Export-Excel {
|
|||||||
[Switch]$FreezeTopRow,
|
[Switch]$FreezeTopRow,
|
||||||
[Switch]$AutoFilter,
|
[Switch]$AutoFilter,
|
||||||
[Switch]$BoldTopRow,
|
[Switch]$BoldTopRow,
|
||||||
[string]$RangeName
|
[string]$RangeName,
|
||||||
|
[string]$TableName
|
||||||
)
|
)
|
||||||
|
|
||||||
Begin {
|
Begin {
|
||||||
@@ -217,6 +218,13 @@ function Export-Excel {
|
|||||||
$dataRange="{0}:{1}" -f $startAddress, $ws.Dimension.End.Address
|
$dataRange="{0}:{1}" -f $startAddress, $ws.Dimension.End.Address
|
||||||
Write-Debug "Data Range $dataRange"
|
Write-Debug "Data Range $dataRange"
|
||||||
|
|
||||||
|
if (-not [string]::IsNullOrEmpty($RangeName)) {
|
||||||
|
$ws.Names.Add($RangeName, $ws.Cells[$dataRange]) | Out-Null
|
||||||
|
}
|
||||||
|
if (-not [string]::IsNullOrEmpty($TableName)) {
|
||||||
|
$ws.Tables.Add($ws.Cells[$dataRange], $TableName) | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
if($IncludePivotTable) {
|
if($IncludePivotTable) {
|
||||||
$pivotTableName = $WorkSheetname + "PivotTable"
|
$pivotTableName = $WorkSheetname + "PivotTable"
|
||||||
$wsPivot = $pkg | Add-WorkSheet -WorkSheetname $pivotTableName -NoClobber:$NoClobber
|
$wsPivot = $pkg | Add-WorkSheet -WorkSheetname $pivotTableName -NoClobber:$NoClobber
|
||||||
@@ -270,6 +278,8 @@ function Export-Excel {
|
|||||||
|
|
||||||
if($AutoSize) { $ws.Cells.AutoFitColumns() }
|
if($AutoSize) { $ws.Cells.AutoFitColumns() }
|
||||||
|
|
||||||
|
#$pkg.Workbook.View.ActiveTab = $ws.SheetID
|
||||||
|
|
||||||
$pkg.Save()
|
$pkg.Save()
|
||||||
$pkg.Dispose()
|
$pkg.Dispose()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user