mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 05:13:49 +00:00
@@ -131,6 +131,7 @@ if ($Artifact) {
|
|||||||
"[Progress] Artifact Start for Module: $ModuleName, Version: $VersionLocal."
|
"[Progress] Artifact Start for Module: $ModuleName, Version: $VersionLocal."
|
||||||
if ($env:APPVEYOR) {
|
if ($env:APPVEYOR) {
|
||||||
$ZipFileName = "{0} {1} {2} {3:yyyy-MM-dd HH-mm-ss}.zip" -f $ModuleName, $VersionLocal, $env:APPVEYOR_REPO_BRANCH, (Get-Date)
|
$ZipFileName = "{0} {1} {2} {3:yyyy-MM-dd HH-mm-ss}.zip" -f $ModuleName, $VersionLocal, $env:APPVEYOR_REPO_BRANCH, (Get-Date)
|
||||||
|
$ZipFileName = $ZipFileName -replace ("[{0}]" -f [RegEx]::Escape([IO.Path]::GetInvalidFileNameChars() -join ''))
|
||||||
$ZipFileFullPath = Join-Path -Path $PSScriptRoot -ChildPath $ZipFileName
|
$ZipFileFullPath = Join-Path -Path $PSScriptRoot -ChildPath $ZipFileName
|
||||||
"[Info] Artifact. $ModuleName, ZipFileName: $ZipFileName."
|
"[Info] Artifact. $ModuleName, ZipFileName: $ZipFileName."
|
||||||
#Compress-Archive -Path $ModulePath -DestinationPath $ZipFileFullPath
|
#Compress-Archive -Path $ModulePath -DestinationPath $ZipFileFullPath
|
||||||
|
|||||||
46
Examples/Experimental/Export-MultipleExcelSheets.ps1
Normal file
46
Examples/Experimental/Export-MultipleExcelSheets.ps1
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
function Export-MultipleExcelSheets {
|
||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Takes a hash table of scriptblocks and exports each as a sheet in an Excel file
|
||||||
|
|
||||||
|
.Example
|
||||||
|
$p = Get-Process
|
||||||
|
|
||||||
|
$InfoMap = @{
|
||||||
|
PM = { $p | Select-Object company, pm }
|
||||||
|
Handles = { $p | Select-Object company, handles }
|
||||||
|
Services = { Get-Service }
|
||||||
|
}
|
||||||
|
|
||||||
|
Export-MultipleExcelSheets -Path $xlfile -InfoMap $InfoMap -Show -AutoSize
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
$Path,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[hashtable]$InfoMap,
|
||||||
|
[string]$Password,
|
||||||
|
[Switch]$Show,
|
||||||
|
[Switch]$AutoSize
|
||||||
|
)
|
||||||
|
|
||||||
|
$parameters = @{ } + $PSBoundParameters
|
||||||
|
$parameters.Remove("InfoMap")
|
||||||
|
$parameters.Remove("Show")
|
||||||
|
|
||||||
|
$parameters.Path = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
|
||||||
|
|
||||||
|
foreach ($entry in $InfoMap.GetEnumerator()) {
|
||||||
|
if ($entry.Value -is [scriptblock]) {
|
||||||
|
Write-Progress -Activity "Exporting" -Status "$($entry.Key)"
|
||||||
|
$parameters.WorkSheetname = $entry.Key
|
||||||
|
|
||||||
|
& $entry.Value | Export-Excel @parameters
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "$($entry.Key) not exported, needs to be a scriptblock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Show) { Invoke-Item $Path }
|
||||||
|
}
|
||||||
17
Examples/Experimental/tryExportMultipleExcelSheets.ps1
Normal file
17
Examples/Experimental/tryExportMultipleExcelSheets.ps1
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
. "$PSScriptRoot\Export-MultipleExcelSheets.ps1"
|
||||||
|
|
||||||
|
$xlfile = "$env:TEMP\test.xlsx"
|
||||||
|
Remove-Item $xlfile -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
$p = Get-Process
|
||||||
|
|
||||||
|
$InfoMap = @{
|
||||||
|
PM = { $p | Select-Object company, pm }
|
||||||
|
Handles = { $p | Select-Object company, handles }
|
||||||
|
Services = { Get-Service }
|
||||||
|
Files = { Get-ChildItem -File }
|
||||||
|
Albums = { ConvertFrom-Csv (Invoke-RestMethod https://raw.githubusercontent.com/dfinke/powershell-for-developers/master/chapter05/BeaverMusic/BeaverMusic.UI.Shell/albums.csv) }
|
||||||
|
WillNotGetExported = "Hello World"
|
||||||
|
}
|
||||||
|
|
||||||
|
Export-MultipleExcelSheets -Path $xlfile -InfoMap $InfoMap -Show -AutoSize
|
||||||
@@ -50,8 +50,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
|||||||
'DoChart',
|
'DoChart',
|
||||||
'Expand-NumberFormat',
|
'Expand-NumberFormat',
|
||||||
'Export-Excel',
|
'Export-Excel',
|
||||||
'Export-ExcelSheet',
|
'Export-ExcelSheet',
|
||||||
'Export-MultipleExcelSheets',
|
|
||||||
'Get-ExcelColumnName',
|
'Get-ExcelColumnName',
|
||||||
'Get-ExcelSheetInfo',
|
'Get-ExcelSheetInfo',
|
||||||
'Get-ExcelWorkbookInfo',
|
'Get-ExcelWorkbookInfo',
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
---
|
|
||||||
external help file: ImportExcel-help.xml
|
|
||||||
Module Name: ImportExcel
|
|
||||||
online version: https://github.com/dfinke/ImportExcel
|
|
||||||
schema: 2.0.0
|
|
||||||
---
|
|
||||||
|
|
||||||
# Export-MultipleExcelSheets
|
|
||||||
|
|
||||||
## SYNOPSIS
|
|
||||||
{{ Fill in the Synopsis }}
|
|
||||||
|
|
||||||
## SYNTAX
|
|
||||||
|
|
||||||
```
|
|
||||||
Export-MultipleExcelSheets [-Path] <Object> [-InfoMap] <Hashtable> [[-Password] <String>] [-Show] [-AutoSize] [<CommonParameters>]
|
|
||||||
```
|
|
||||||
|
|
||||||
## DESCRIPTION
|
|
||||||
{{ Fill in the Description }}
|
|
||||||
|
|
||||||
## EXAMPLES
|
|
||||||
|
|
||||||
### Example 1
|
|
||||||
```powershell
|
|
||||||
PS C:\> {{ Add example code here }}
|
|
||||||
```
|
|
||||||
|
|
||||||
{{ Add example description here }}
|
|
||||||
|
|
||||||
## PARAMETERS
|
|
||||||
|
|
||||||
### -AutoSize
|
|
||||||
{{ Fill AutoSize Description }}
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
Type: SwitchParameter
|
|
||||||
Parameter Sets: (All)
|
|
||||||
Aliases:
|
|
||||||
|
|
||||||
Required: False
|
|
||||||
Position: Named
|
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
|
||||||
Accept wildcard characters: False
|
|
||||||
```
|
|
||||||
|
|
||||||
### -InfoMap
|
|
||||||
{{ Fill InfoMap Description }}
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
Type: Hashtable
|
|
||||||
Parameter Sets: (All)
|
|
||||||
Aliases:
|
|
||||||
|
|
||||||
Required: True
|
|
||||||
Position: 1
|
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
|
||||||
Accept wildcard characters: False
|
|
||||||
```
|
|
||||||
|
|
||||||
### -Password
|
|
||||||
{{ Fill Password Description }}
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
Type: String
|
|
||||||
Parameter Sets: (All)
|
|
||||||
Aliases:
|
|
||||||
|
|
||||||
Required: False
|
|
||||||
Position: 2
|
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
|
||||||
Accept wildcard characters: False
|
|
||||||
```
|
|
||||||
|
|
||||||
### -Path
|
|
||||||
{{ Fill Path Description }}
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
Type: Object
|
|
||||||
Parameter Sets: (All)
|
|
||||||
Aliases:
|
|
||||||
|
|
||||||
Required: True
|
|
||||||
Position: 0
|
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
|
||||||
Accept wildcard characters: False
|
|
||||||
```
|
|
||||||
|
|
||||||
### -Show
|
|
||||||
{{ Fill Show Description }}
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
Type: SwitchParameter
|
|
||||||
Parameter Sets: (All)
|
|
||||||
Aliases:
|
|
||||||
|
|
||||||
Required: False
|
|
||||||
Position: Named
|
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
|
||||||
Accept wildcard characters: False
|
|
||||||
```
|
|
||||||
|
|
||||||
### CommonParameters
|
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
|
||||||
|
|
||||||
## INPUTS
|
|
||||||
|
|
||||||
### None
|
|
||||||
|
|
||||||
## OUTPUTS
|
|
||||||
|
|
||||||
### System.Object
|
|
||||||
## NOTES
|
|
||||||
|
|
||||||
## RELATED LINKS
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
function Export-MultipleExcelSheets {
|
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")]
|
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification="No suitable singular")]
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
$Path,
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[hashtable]$InfoMap,
|
|
||||||
[string]$Password,
|
|
||||||
[Switch]$Show,
|
|
||||||
[Switch]$AutoSize
|
|
||||||
)
|
|
||||||
|
|
||||||
$parameters = @{ } + $PSBoundParameters
|
|
||||||
$parameters.Remove("InfoMap")
|
|
||||||
$parameters.Remove("Show")
|
|
||||||
|
|
||||||
$parameters.Path = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
|
|
||||||
|
|
||||||
foreach ($entry in $InfoMap.GetEnumerator()) {
|
|
||||||
Write-Progress -Activity "Exporting" -Status "$($entry.Key)"
|
|
||||||
$parameters.WorkSheetname = $entry.Key
|
|
||||||
|
|
||||||
& $entry.Value | Export-Excel @parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($Show) { Invoke-Item $Path }
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user