mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 13:23:29 +00:00
Trying out PassThru
This commit is contained in:
@@ -51,7 +51,8 @@ function Export-Excel {
|
||||
[Switch]$KillExcel,
|
||||
[Switch]$AutoNameRange,
|
||||
$StartRow=1,
|
||||
$StartColumn=1
|
||||
$StartColumn=1,
|
||||
[Switch]$PassThru
|
||||
)
|
||||
|
||||
Begin {
|
||||
@@ -360,9 +361,13 @@ function Export-Excel {
|
||||
}
|
||||
}
|
||||
|
||||
$pkg.Save()
|
||||
$pkg.Dispose()
|
||||
if($PassThru) {
|
||||
$pkg
|
||||
} else {
|
||||
$pkg.Save()
|
||||
$pkg.Dispose()
|
||||
|
||||
if($Show) {Invoke-Item $Path}
|
||||
if($Show) {Invoke-Item $Path}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
29
README.md
29
README.md
@@ -16,6 +16,35 @@ To install in your personal modules folder (e.g. ~\Documents\WindowsPowerShell\M
|
||||
iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/dfinke/ImportExcel/master/Install.ps1')
|
||||
```
|
||||
|
||||
## Try *PassThru*
|
||||
|
||||
```powershell
|
||||
$file = "C:\Temp\passthru.xlsx"
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
$xlPkg = $(
|
||||
New-PSItem north 10
|
||||
New-PSItem east 20
|
||||
New-PSItem west 30
|
||||
New-PSItem south 40
|
||||
) | Export-Excel $file -PassThru
|
||||
|
||||
|
||||
$ws=$xlPkg.Workbook.Worksheets[1]
|
||||
|
||||
$ws.Cells["A3"].Value = "Hello World"
|
||||
$ws.Cells["B3"].Value = "Updating cells"
|
||||
$ws.Cells["D1:D5"].Value = "Data"
|
||||
|
||||
$ws.Cells.AutoFitColumns()
|
||||
|
||||
$xlPkg.Save()
|
||||
$xlPkg.Dispose()
|
||||
|
||||
Invoke-Item $file
|
||||
```
|
||||
|
||||
|
||||
Known Issues
|
||||
-
|
||||
* Using `-IncludePivotTable`, if that pivot table name exists, you'll get an error.
|
||||
|
||||
Reference in New Issue
Block a user