mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Replaced -Force switch with -NoClobber switch
This commit is contained in:
@@ -59,7 +59,7 @@ function Export-Excel {
|
||||
[Switch]$IncludePivotChart,
|
||||
[Switch]$AutoSize,
|
||||
[Switch]$Show,
|
||||
[Switch]$Force
|
||||
[Switch]$NoClobber
|
||||
)
|
||||
|
||||
Begin {
|
||||
@@ -68,13 +68,22 @@ function Export-Excel {
|
||||
$pkg = New-Object OfficeOpenXml.ExcelPackage $Path
|
||||
|
||||
if($pkg.Workbook.Worksheets[$WorkSheetname]) {
|
||||
$pkg.Workbook.Worksheets.delete($WorkSheetname)
|
||||
if($NoClobber) {
|
||||
$AlreadyExists = $true
|
||||
throw ""
|
||||
} else {
|
||||
$pkg.Workbook.Worksheets.delete($WorkSheetname)
|
||||
}
|
||||
}
|
||||
|
||||
$ws = $pkg.Workbook.Worksheets.Add($WorkSheetname)
|
||||
$Row = 1
|
||||
} Catch {
|
||||
throw $Error[0].Exception.InnerException
|
||||
if($AlreadyExists) {
|
||||
throw "$WorkSheetname already exists."
|
||||
} else {
|
||||
throw $Error[0].Exception.InnerException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ What's new
|
||||
#### 4/10/2015
|
||||
* Renamed `AutoFitColumns` to `AutoSize`
|
||||
* Implemented `Export-MultipleExcelSheets`
|
||||
* Implemented `-Password` for a worksheet
|
||||
* Implemented `-Password` for a worksheet
|
||||
* Repalce `-Force` switch with `-NoClobber` switch
|
||||
|
||||
#### Examples
|
||||
`gsv | Export-Excel .\test.xlsx -WorkSheetname Services`
|
||||
|
||||
Reference in New Issue
Block a user