Compare commits

..

31 Commits

Author SHA1 Message Date
dfinke
933abf6539 Tweaked format 2020-03-16 13:39:03 -04:00
dfinke
6a32da7f92 update readme 2020-03-16 13:34:31 -04:00
dfinke
c3ac68ea2c bump version 2020-03-16 13:34:05 -04:00
Doug Finke
5ea9b1d082 Merge pull request #803 from jhoneill/master
fix #802 and #795. Extra examples including pester-xlsx
2020-03-16 12:50:52 -04:00
jhoneill
ae64a884fc Put back asDate lost in merge 2020-03-16 12:10:51 +00:00
jhoneill
b584b22f5f Merge remote-tracking branch 'upstream/master' 2020-03-16 11:43:10 +00:00
jhoneill
eb3a7d3f2d Allow 0 or false to be a column heading 2020-03-16 11:15:40 +00:00
jhoneill
3130020e20 apply freeze to 2 rows if title present #795 2020-03-16 11:10:44 +00:00
jhoneill
fe68ddbb0d New examples incl. Pester to XLSx 2020-03-16 11:07:30 +00:00
Doug Finke
1ce65a0758 Merge pull request #793 from dfinke/FixSheetHasOnlyHeaders
Spike to fix #792
2020-03-01 08:04:45 -05:00
dfinke
13454cce8e Spike to fix #792 2020-02-29 15:55:49 -05:00
Doug Finke
96b61d38f1 Merge pull request #783 from clsmith70/patch-2
Create MultipleWorksheets.ps1
2020-02-18 09:09:41 -05:00
Chris Smith
59e31d54a7 Move to /Examples/CommunityContributions Folder 2020-02-18 09:02:49 -05:00
Chris Smith
6bf16f75f7 Create MultipleWorksheets.ps1
The PS commands to create an Excel file with multiple worksheets and adding one using ExcelPackage functions.
2020-02-16 16:37:27 -05:00
Doug Finke
c547713ee9 Merge pull request #782 from JustinGrote/patch-1
Remove Write-Debug Performance Outputs
2020-02-15 07:13:39 -05:00
Justin Grote
f0ec5f4a96 Remove Write-Debug Performance Outputs
These outputs are unnecessary and can confuse someone observing other debug output.
2020-02-14 14:49:07 -08:00
Doug Finke
7ded94e225 Merge pull request #775 from stahler/master
Update help for GroupDateRow parameter. Thanks for the update Wes (@stahler)!
2020-02-11 18:25:01 -05:00
Wes Stahler
4141ba690e Update New-PivotTableDefinition.md 2020-02-11 08:39:24 -05:00
Wes Stahler
08ecadddb2 Merge pull request #1 from dfinke/master
Update
2020-02-11 08:24:41 -05:00
dfinke
e42f42fde9 Add VLookup 2020-02-03 20:19:57 -05:00
dfinke
12fa49e314 Rename directory 2020-02-03 20:11:49 -05:00
dfinke
98ce564929 Add Excel builtin DSUM Example 2020-02-01 11:55:33 -05:00
jhoneill
7e75ecd0fb Add Subtotals & Groups example 2019-12-31 22:32:34 +00:00
jhoneill
17ec040055 fix message in merge, improve pester example 2019-12-31 19:38:28 +00:00
jhoneill
e65210e378 Fix test not working with single digit dates. 2019-12-31 02:48:57 +00:00
jhoneill
7bfb28d10f Update Pester Syntax from V3 to V4 (V5 won't support the old version) 2019-12-29 17:18:24 +00:00
jhoneill
08fbfc35a3 Add Pester example. Make Hide and Hidden aliases 2019-12-28 21:16:01 +00:00
jhoneill
4315ddc702 Merge branch 'master' of https://github.com/dfinke/ImportExcel 2019-12-22 18:38:12 +00:00
jhoneill
97611fc57c Add -AsDate support to import-Excel and ConvertFrom-Excel sheet. Help upate 2019-12-22 18:04:42 +00:00
jhoneill
118330ea47 Make primary name "PivotTableChartType" (with alias chartType) in Export-Excel 2019-12-22 16:39:38 +00:00
jhoneill
6f48219819 assume IncludePivot when implied by other params 2019-12-22 14:52:06 +00:00
49 changed files with 2129 additions and 1388 deletions

View File

@@ -0,0 +1,27 @@
<#
To see this written up with example screenshots, head over to the IT Splat blog
URL: http://bit.ly/2SxieeM
#>
## Create an Excel file with multiple worksheets
# Get a list of processes on the system
$processes = Get-Process | Sort-Object -Property ProcessName | Group-Object -Property ProcessName | Where-Object {$_.Count -gt 2}
# Export the processes to Excel, each process on its own sheet
$processes | ForEach-Object { $_.Group | Export-Excel -Path MultiSheetExample.xlsx -WorksheetName $_.Name -AutoSize -AutoFilter }
# Show the completed file
Invoke-Item .\MultiSheetExample.xlsx
## Add an additional sheet to the new workbook
# Use Open-ExcelPackage to open the workbook
$excelPackage = Open-ExcelPackage -Path .\MultiSheetExample.xlsx
# Create a new worksheet and give it a name, set MoveToStart to make it the first sheet
$ws = Add-Worksheet -ExcelPackage $excelPackage -WorksheetName 'All Services' -MoveToStart
# Get all the running services on the system
Get-Service | Export-Excel -ExcelPackage $excelPackage -WorksheetName $ws -AutoSize -AutoFilter
# Close the package and show the final result
Close-ExcelPackage -ExcelPackage $excelPackage -Show

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -0,0 +1,31 @@
# DSUM
# Adds the numbers in a field (column) of records in a list or database that match conditions that you specify.
$xlfile = "$env:TEMP\test.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
$data = ConvertFrom-Csv @"
Color,Date,Sales
Red,1/15/2018,250
Blue,1/15/2018,200
Red,1/16/2018,175
Blue,1/16/2018,325
Red,1/17/2018,150
Blue,1/17/2018,300
"@
$xl = Export-Excel -InputObject $data -Path $xlfile -AutoSize -AutoFilter -TableName SalesInfo -AutoNameRange -PassThru
$databaseAddress = $xl.Sheet1.Dimension.Address
Set-Format -Worksheet $xl.Sheet1 -Range C:C -NumberFormat '$##0'
Set-Format -Worksheet $xl.Sheet1 -Range E1 -Value Color
Set-Format -Worksheet $xl.Sheet1 -Range F1 -Value Date
Set-Format -Worksheet $xl.Sheet1 -Range G1 -Value Sales
Set-Format -Worksheet $xl.Sheet1 -Range E2 -Value Red
Set-Format -Worksheet $xl.Sheet1 -Range E4 -Value Sales
Set-Format -Worksheet $xl.Sheet1 -Range F4 -Formula ('=DSUM({0},"Sales",E1:G2)' -f $databaseAddress) -NumberFormat '$##0'
Close-ExcelPackage $xl -Show

View File

@@ -0,0 +1,19 @@
$xlfile = "$env:TEMP\test.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
$data = ConvertFrom-Csv @"
Fruit,Amount
Apples,50
Oranges,20
Bananas,60
Lemons,40
"@
$xl = Export-Excel -InputObject $data -Path $xlfile -PassThru -AutoSize
Set-ExcelRange -Worksheet $xl.Sheet1 -Range D2 -BackgroundColor LightBlue -Value Apples
$Rows = $xl.Sheet1.Dimension.Rows
Set-ExcelRange -Worksheet $xl.Sheet1 -Range E2 -Formula "=VLookup(D2,A2:B$($Rows),2,FALSE)"
Close-ExcelPackage $xl -Show

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

147
Examples/Pester-To-XLSx.ps1 Normal file
View File

@@ -0,0 +1,147 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSPossibleIncorrectComparisonWithNull', '', Justification = 'Intentional use to select non null array items')]
[CmdletBinding(DefaultParameterSetName = 'Default')]
param(
[Parameter(Position = 0)]
[string]$XLFile,
[Parameter(ParameterSetName = 'Default', Position = 1)]
[Alias('Path', 'relative_path')]
[object[]]$Script = '.',
[Parameter(ParameterSetName = 'Existing', Mandatory = $true)]
[switch]
$UseExisting,
[Parameter(ParameterSetName = 'Default', Position = 2)]
[Parameter(ParameterSetName = 'Existing', Position = 2, Mandatory = $true)]
[string]$OutputFile,
[Parameter(ParameterSetName = 'Default')]
[Alias("Name")]
[string[]]$TestName,
[Parameter(ParameterSetName = 'Default')]
[switch]$EnableExit,
[Parameter(ParameterSetName = 'Default')]
[Alias('Tags')]
[string[]]$Tag,
[string[]]$ExcludeTag,
[Parameter(ParameterSetName = 'Default')]
[switch]$Strict,
[string]$WorkSheetName = 'PesterResults',
[switch]$append,
[switch]$Show
)
$InvokePesterParams = @{OutputFormat = 'NUnitXml' } + $PSBoundParameters
if (-not $InvokePesterParams['OutputFile']) {
$InvokePesterParams['OutputFile'] = Join-Path -ChildPath 'Pester.xml'-Path ([environment]::GetFolderPath([System.Environment+SpecialFolder]::MyDocuments))
}
if ($InvokePesterParams['Show'] ) { }
if ($InvokePesterParams['XLFile']) { $InvokePesterParams.Remove('XLFile') }
else { $XLFile = $InvokePesterParams['OutputFile'] -replace '.xml$', '.xlsx' }
if (-not $UseExisting) {
$InvokePesterParams.Remove('Append')
$InvokePesterParams.Remove('UseExisting')
$InvokePesterParams.Remove('Show')
$InvokePesterParams.Remove('WorkSheetName')
Invoke-Pester @InvokePesterParams
}
if (-not (Test-Path -Path $InvokePesterParams['OutputFile'])) {
throw "Could not output file $($InvokePesterParams['OutputFile'])"; return
}
$resultXML = ([xml](Get-Content $InvokePesterParams['OutputFile'])).'test-results'
$startDate = [datetime]$resultXML.date
$startTime = $resultXML.time
$machine = $resultXML.environment.'machine-name'
#$user = $resultXML.environment.'user-domain' + '\' + $resultXML.environment.user
$os = $resultXML.environment.platform -replace '\|.*$', " $($resultXML.environment.'os-version')"
<#hierarchy goes
root, [date], start [time], [Name] (always "Pester"), test results broken down as [total],[errors],[failures],[not-run] etc.
Environment (user & machine info)
Culture-Info (current, and currentUi culture)
Test-Suite [name] = "Pester" [result], [time] to execute, etc.
Results
Test-Suite [name] = filename,[result], [Time] to Execute etc
Results
Test-Suite [Name] = Describe block Name, [result], [Time] to execute etc..
Results
Test-Suite [Name] = Context block name [result], [Time] to execute etc.
Results
Test-Case [name] = Describe.Context.It block names [description]= it block name, result], [Time] to execute etc
or if the tests are parameterized
Test suite [description] - name in the the it block with <vars> not filled in
Results
Test-case [description] - name as rendered for display with <vars> filled in
#>
$testResults = foreach ($test in $resultXML.'test-suite'.results.'test-suite') {
$testPs1File = $test.name
#Test if there are context blocks in the hierarchy OR if we go straight from Describe to test-case
if ($test.results.'test-suite'.results.'test-suite' -ne $null) {
foreach ($suite in $test.results.'test-suite') {
$Describe = $suite.description
foreach ($subsuite in $suite.results.'test-suite') {
$Context = $subsuite.description
if ($subsuite.results.'test-suite'.results.'test-case') {
$testCases = $subsuite.results.'test-suite'.results.'test-case'
}
else { $testCases = $subsuite.results.'test-case' }
$testCases | ForEach-Object {
New-Object -TypeName psobject -Property ([ordered]@{
Machine = $machine ; OS = $os
Date = $startDate ; Time = $startTime
Executed = $(if ($_.executed -eq 'True') { 1 })
Success = $(if ($_.success -eq 'True') { 1 })
Duration = $_.time
File = $testPs1File; Group = $Describe
SubGroup = $Context ; Name = ($_.Description -replace '\s{2,}', ' ')
Result = $_.result ; FullDesc = '=Group&" "&SubGroup&" "&Name'
})
}
}
}
}
else {
$test.results.'test-suite' | ForEach-Object {
$Describe = $_.description
$_.results.'test-case' | ForEach-Object {
New-Object -TypeName psobject -Property ([ordered]@{
Machine = $machine ; OS = $os
Date = $startDate ; Time = $startTime
Executed = $(if ($_.executed -eq 'True') { 1 })
Success = $(if ($_.success -eq 'True') { 1 })
Duration = $_.time
File = $testPs1File; Group = $Describe
SubGroup = $null ; Name = ($_.Description -replace '\s{2,}', ' ')
Result = $_.result ; FullDesc = '=Group&" "&Test'
})
}
}
}
}
if (-not $testResults) { Write-Warning 'No Results found' ; return }
$clearSheet = -not $Append
$excel = $testResults | Export-Excel -Path $xlFile -WorkSheetname $WorkSheetName -ClearSheet:$clearSheet -Append:$append -PassThru -BoldTopRow -FreezeTopRow -AutoSize -AutoFilter -AutoNameRange
$ws = $excel.Workbook.Worksheets[$WorkSheetName]
<# Worksheet should look like ..
|A |B |C D |E |F |G |H |I |J |K |L |M
1|Machine |OS |Date Time |Executed |Success |Duration |File |Group |SubGroup |Name |Result |FullDescription
2|Flatfish |Name_Version |[run started] |Boolean |Boolean |In seconds |xx.ps1 |Describe |Context |It |Success |Desc_Context_It
#>
#Display Date as a date, not a date time
Set-Column -Worksheet $ws -Column 3 -NumberFormat 'Short Date' # -AutoSize
#Hide columns E to J (Executed, Success, Duration, File, Group and Subgroup)
(5..10) | ForEach-Object { Set-ExcelColumn -Worksheet $ws -Column $_ -Hide }
#Use conditional formatting to make Failures red, and Successes green (skipped remains black ) ... and save
$endRow = $ws.Dimension.End.Row
Add-ConditionalFormatting -WorkSheet $ws -range "L2:L$endrow" -RuleType ContainsText -ConditionValue "Failure" -BackgroundPattern None -ForegroundColor Red -Bold
Add-ConditionalFormatting -WorkSheet $ws -range "L2:L$endRow" -RuleType ContainsText -ConditionValue "Success" -BackgroundPattern None -ForeGroundColor Green
Close-ExcelPackage -ExcelPackage $excel -Show:$show

21
Examples/PsGallery.ps1 Normal file
View File

@@ -0,0 +1,21 @@
$top1000 = foreach ($p in 1..50) {
$c = Invoke-WebRequest -Uri "https://www.powershellgallery.com/packages" -method Post -Body "q=&sortOrder=package-download-count&page=$p"
[regex]::Matches($c.Content,'<table class="width-hundred-percent">.*?</table>', [System.Text.RegularExpressions.RegexOptions]::Singleline) | foreach {
$name = [regex]::Match($_, "(?<=<h1><a href=.*?>).*(?=</a></h1>)").value
$n = [regex]::replace($_,'^.*By:\s*<li role="menuitem">','', [System.Text.RegularExpressions.RegexOptions]::Singleline)
$n = [regex]::replace($n,'</div>.*$','', [System.Text.RegularExpressions.RegexOptions]::Singleline)
$by = [regex]::match($n,'(?<=">).*(?=</a>)').value
$qty = [regex]::match($n,'\S*(?= downloads)').value
[PSCustomObject]@{
Name = $name
by = $by
Downloads = $qty
}
}
}
del "~\Documents\gallery.xlsx"
$pivotdef = New-PivotTableDefinition -PivotTableName 'Summary' -PivotRows by -PivotData @{name="Count"
Downloads="Sum"} -PivotDataToColumn -Activate -ChartType ColumnClustered -PivotNumberFormat '#,###'
$top1000 | export-excel -path '~\Documents\gallery.xlsx' -Numberformat '#,###' -PivotTableDefinition $pivotdef -TableName 'TopDownloads' -Show

78
Examples/Subtotals.ps1 Normal file
View File

@@ -0,0 +1,78 @@
$Data = ConvertFrom-Csv @'
Product, City, Gross, Net
Apple, London , 300, 250
Orange, London , 400, 350
Banana, London , 300, 200
Grape, Munich, 100, 100
Orange, Paris, 600, 500
Banana, Paris, 300, 200
Apple, New York, 1200,700
'@
$ExcelPath = "$env:temp\subtotal.xlsx"
$SheetName = 'Sheet1'
Remove-Item -Path $ExcelPath -ErrorAction SilentlyContinue
$GroupByFieldName = 'City'
$TotalSingleRows = $false
$GrandTotal = $false
$SubtotalRowHeight = 0 #If non zero will set subtotals to this height
$Subtotals =@{ 'Net' = {"=SUBTOTAL(3,D{0}:D{1})" -f $from, $to}
}
$SubtotalFieldName = 'Net'
$SubtotalFormula = '=SUBTOTAL(3,D{0}:D{1})' # {0} and {1} are placeholders for the first and last row. D is the column to total in
# 1=AVERAGE; 2=COUNT; 3=COUNTA; 4=MAX; 5=MIN; 6=PRODUCT; 7=STDEV; 8=STDEVP; 9=SUM; 10=VAR; 11=VARP add 100 to ignore hidden values
#at each change in the Group by field, insert a subtotal (count) formula in the title column & send to excel - list those rows and make them half height after export
$currentRow = 2
$lastChangeRow = 2
$insertedRows = @()
#$hideRows = @()
$lastValue = $Data[0].$GroupByFieldName
$excel = $Data | ForEach-Object -Process {
if ($_.$GroupByFieldName -ne $lastvalue) {
if ($lastChangeRow -lt ($currentrow - 1) -or $totalSingleRows) {
$formula = $SubtotalFormula -f $lastChangeRow, ($currentrow - 1)
$insertedRows += $currentRow
[pscustomobject]@{$SubtotalFieldName = $formula}
$currentRow += 1
}
$lastChangeRow = $currentRow
$lastValue = $_.$GroupByFieldName
}
$_
$currentRow += 1
} -end {
$formula = $SubtotalFormula -f $lastChangeRow, ($currentrow - 1)
[pscustomobject]@{$SubtotalFieldName=$formula}
if ($GrandTotal) {
$formula = $SubtotalFormula -f $lastChangeRow, ($currentrow - 1)
[pscustomobject]@{$SubtotalFieldName=$formula}
}
} | Export-Excel -Path $ExcelPath -PassThru -AutoSize -AutoFilter -BoldTopRow -WorksheetName $sheetName
#We kept a lists of the total rows. Since single rows won't get expanded/collapsed hide them.
if ($subtotalrowHeight) {
foreach ($r in $insertedrows) { $excel.WorkItems.Row($r).Height = $SubtotalRowHeight}
}
#foreach ($r in $hideRows) { $excel.$SheetName.Row($r).hidden = $true}
$range = $excel.$SheetName.Dimension.Address
$sheetIndex = $excel.Sheet1.Index
Close-ExcelPackage -ExcelPackage $excel
try { $excelApp = New-Object -ComObject "Excel.Application" }
catch { Write-Warning "Could not start Excel application - which usually means it is not installed." ; return }
try { $excelWorkBook = $excelApp.Workbooks.Open($ExcelPath) }
catch { Write-Warning -Message "Could not Open $ExcelPath." ; return }
$ws = $excelWorkBook.Worksheets.Item($sheetIndex)
$null = $ws.Range($range).Select()
$null = $excelapp.Selection.AutoOutline()
$excelWorkBook.Save()
$excelWorkBook.Close()
$excelApp.Quit()
Start-Process $ExcelPath

View File

@@ -29,7 +29,7 @@ function ConvertTo-PesterTest {
`$target.psobject.Properties.name | ForEach-Object {`$p=@{}} {`$p.`$_=`$(`$target.`$_)} `$target.psobject.Properties.name | ForEach-Object {`$p=@{}} {`$p.`$_=`$(`$target.`$_)}
Invoke-RestMethod @p | Should Be '$($record.ExpectedResult)' Invoke-RestMethod @p | Should -Be '$($record.ExpectedResult)'
} }
"@ "@

View File

@@ -30,7 +30,7 @@ function Test-APIReadXls {
`$target.psobject.Properties.name | ForEach-Object {`$p=@{}} {`$p.`$_=`$(`$target.`$_)} `$target.psobject.Properties.name | ForEach-Object {`$p=@{}} {`$p.`$_=`$(`$target.`$_)}
Invoke-RestMethod @p | Should Be '$($record.ExpectedResult)' Invoke-RestMethod @p | Should -Be '$($record.ExpectedResult)'
} }
"@ "@

View File

@@ -6,7 +6,7 @@
RootModule = 'ImportExcel.psm1' RootModule = 'ImportExcel.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '7.0.1' ModuleVersion = '7.1.0'
# ID used to uniquely identify this module # ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede' GUID = '60dd4136-feff-401a-ba27-a84458c57ede'

View File

@@ -1,140 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version:
schema: 2.0.0
---
# ConvertFrom-ExcelSheet
## SYNOPSIS
Reads an Excel file an converts the data to a delimited text file.
## SYNTAX
```
ConvertFrom-ExcelSheet [-Path] <String> [[-OutputPath] <String>] [[-SheetName] <String>] [[-Encoding] <String>]
[[-Extension] <String>] [[-Delimiter] <String>] [<CommonParameters>]
```
## DESCRIPTION
{{ Fill in the Description }}
## EXAMPLES
### EXAMPLE 1
```
ConvertFrom-ExcelSheet .\TestSheets.xlsx .\data
```
Reads each sheet in TestSheets.xlsx and outputs it to the data directory as the sheet name with the extension .txt.
### EXAMPLE 2
```
ConvertFrom-ExcelSheet .\TestSheets.xlsx .\data sheet?0
```
Reads and outputs sheets like Sheet10 and Sheet20 form TestSheets.xlsx and outputs it to the data directory as the sheet name with the extension .txt.
## PARAMETERS
### -Path
{{ Fill Path Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases: FullName
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -OutputPath
{{ Fill OutputPath Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: .\
Accept pipeline input: False
Accept wildcard characters: False
```
### -SheetName
{{ Fill SheetName Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: *
Accept pipeline input: False
Accept wildcard characters: False
```
### -Encoding
{{ Fill Encoding Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: UTF8
Accept pipeline input: False
Accept wildcard characters: False
```
### -Extension
{{ Fill Extension Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: .csv
Accept pipeline input: False
Accept wildcard characters: False
```
### -Delimiter
{{ Fill Delimiter Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: ;
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
## OUTPUTS
## NOTES
## RELATED LINKS

View File

@@ -15,7 +15,8 @@ function ConvertFrom-ExcelSheet {
$Property = "*", $Property = "*",
$ExcludeProperty = @(), $ExcludeProperty = @(),
[switch]$Append, [switch]$Append,
[string[]]$AsText = @() [string[]]$AsText = @(),
[string[]]$AsDate = @()
) )
$Path = (Resolve-Path $Path).Path $Path = (Resolve-Path $Path).Path
@@ -25,7 +26,7 @@ function ConvertFrom-ExcelSheet {
$targetSheets = $workbook.Worksheets | Where-Object {$_.Name -Like $SheetName} $targetSheets = $workbook.Worksheets | Where-Object {$_.Name -Like $SheetName}
$csvParams = @{NoTypeInformation = $true} + $PSBoundParameters $csvParams = @{NoTypeInformation = $true} + $PSBoundParameters
foreach ($p in 'OutputPath', 'SheetName', 'Extension', 'Property','ExcludeProperty', 'AsText') { foreach ($p in 'OutputPath', 'SheetName', 'Extension', 'Property','ExcludeProperty', 'AsText','AsDate') {
$csvParams.Remove($p) $csvParams.Remove($p)
} }
@@ -34,7 +35,7 @@ function ConvertFrom-ExcelSheet {
$csvParams.Path = "$OutputPath\$($Sheet.Name)$Extension" $csvParams.Path = "$OutputPath\$($Sheet.Name)$Extension"
Import-Excel -ExcelPackage $xl -Sheet $($sheet.Name) -AsText:$AsText | Import-Excel -ExcelPackage $xl -Sheet $($sheet.Name) -AsText:$AsText -AsDate:$AsDate |
Select-Object -Property $Property | Export-Csv @csvparams Select-Object -Property $Property | Export-Csv @csvparams
} }

View File

@@ -22,6 +22,7 @@
[Switch]$TitleBold, [Switch]$TitleBold,
[Int]$TitleSize = 22, [Int]$TitleSize = 22,
$TitleBackgroundColor, $TitleBackgroundColor,
[parameter(DontShow=$true)]
[Switch]$IncludePivotTable, [Switch]$IncludePivotTable,
[String]$PivotTableName, [String]$PivotTableName,
[String[]]$PivotRows, [String[]]$PivotRows,
@@ -31,7 +32,8 @@
[Switch]$PivotDataToColumn, [Switch]$PivotDataToColumn,
[Hashtable]$PivotTableDefinition, [Hashtable]$PivotTableDefinition,
[Switch]$IncludePivotChart, [Switch]$IncludePivotChart,
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType = 'Pie', [Alias('ChartType')]
[OfficeOpenXml.Drawing.Chart.eChartType]$PivotChartType = 'Pie',
[Switch]$NoLegend, [Switch]$NoLegend,
[Switch]$ShowCategory, [Switch]$ShowCategory,
[Switch]$ShowPercent, [Switch]$ShowPercent,
@@ -442,7 +444,7 @@
Add-PivotTable -ExcelPackage $pkg -PivotTableName $item.key @Params Add-PivotTable -ExcelPackage $pkg -PivotTableName $item.key @Params
} }
} }
if ($IncludePivotTable -or $IncludePivotChart) { if ($IncludePivotTable -or $IncludePivotChart -or $PivotData) {
$params = @{ $params = @{
'SourceRange' = $dataRange 'SourceRange' = $dataRange
} }
@@ -461,9 +463,10 @@
if ($NoTotalsInPivot) {$params.PivotTotals = "None" } if ($NoTotalsInPivot) {$params.PivotTotals = "None" }
Elseif ($PivotTotals) {$params.PivotTotals = $PivotTotals} Elseif ($PivotTotals) {$params.PivotTotals = $PivotTotals}
if ($PivotDataToColumn) {$params.PivotDataToColumn = $true} if ($PivotDataToColumn) {$params.PivotDataToColumn = $true}
if ($IncludePivotChart) { if ($IncludePivotChart -or
$PSBoundParameters.ContainsKey('PivotChartType')) {
$params.IncludePivotChart = $true $params.IncludePivotChart = $true
$Params.ChartType = $ChartType $Params.ChartType = $PivotChartType
if ($ShowCategory) {$params.ShowCategory = $true} if ($ShowCategory) {$params.ShowCategory = $true}
if ($ShowPercent) {$params.ShowPercent = $true} if ($ShowPercent) {$params.ShowPercent = $true}
if ($NoLegend) {$params.NoLegend = $true} if ($NoLegend) {$params.NoLegend = $true}
@@ -474,12 +477,24 @@
try { try {
#Allow single switch or two seperate ones. #Allow single switch or two seperate ones.
if ($FreezeTopRowFirstColumn -or ($FreezeTopRow -and $FreezeFirstColumn)) { if ($FreezeTopRowFirstColumn -or ($FreezeTopRow -and $FreezeFirstColumn)) {
$ws.View.FreezePanes(2, 2) if ($Title) {
Write-Verbose -Message "Froze top row and first column" $ws.View.FreezePanes(3, 2)
Write-Verbose -Message "Froze title and header rows and first column"
}
else {
$ws.View.FreezePanes(2, 2)
Write-Verbose -Message "Froze top row and first column"
}
} }
elseif ($FreezeTopRow) { elseif ($FreezeTopRow) {
$ws.View.FreezePanes(2, 1) if ($Title) {
Write-Verbose -Message "Froze top row" $ws.View.FreezePanes(2, 1)
Write-Verbose -Message "Froze title and header rows"
}
else {
$ws.View.FreezePanes(2, 1)
Write-Verbose -Message "Froze top row"
}
} }
elseif ($FreezeFirstColumn) { elseif ($FreezeFirstColumn) {
$ws.View.FreezePanes(1, 2) $ws.View.FreezePanes(1, 2)

View File

@@ -1,8 +1,8 @@
function Import-Excel { function Import-Excel {
[CmdLetBinding()] [CmdLetBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSPossibleIncorrectUsageOfAssignmentOperator', '', Justification = 'Intentional')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSPossibleIncorrectUsageOfAssignmentOperator', '', Justification = 'Intentional')]
param ( param (
[Alias('FullName')] [Alias('FullName')]
[Parameter(ParameterSetName = "PathA", Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline, Position = 0 )] [Parameter(ParameterSetName = "PathA", Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline, Position = 0 )]
[Parameter(ParameterSetName = "PathB", Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline, Position = 0 )] [Parameter(ParameterSetName = "PathB", Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline, Position = 0 )]
@@ -33,170 +33,190 @@
[Int]$EndColumn , [Int]$EndColumn ,
[Switch]$DataOnly, [Switch]$DataOnly,
[string[]]$AsText, [string[]]$AsText,
[string[]]$AsDate,
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[String]$Password [String]$Password
) )
end { end {
$sw = [System.Diagnostics.Stopwatch]::StartNew() $sw = [System.Diagnostics.Stopwatch]::StartNew()
if ($input) { if ($input) {
$Paths = $input $Paths = $input
}
elseif ($Path) {
$Paths = $Path
}
else {
$Paths = ''
}
function Get-PropertyNames {
<#
.SYNOPSIS
Create objects containing the column number and the column name for each of the different header types.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = "Name would be incorrect, and command is not exported")]
param(
[Parameter(Mandatory)]
[Int[]]$Columns,
[Parameter(Mandatory)]
[Int]$StartRow
)
try {
if ($HeaderName) {
$i = 0
foreach ($H in $HeaderName) {
$H | Select-Object @{N = 'Column'; E = { $Columns[$i] } }, @{N = 'Value'; E = { $H } }
$i++
}
}
elseif ($NoHeader) {
$i = 0
foreach ($C in $Columns) {
$i++
$C | Select-Object @{N = 'Column'; E = { $_ } }, @{N = 'Value'; E = { 'P' + $i } }
}
}
else {
if ($StartRow -lt 1) {
throw 'The top row can never be less than 1 when we need to retrieve headers from the worksheet.' ; return
}
foreach ($C in $Columns) {
$Worksheet.Cells[$StartRow, $C] | Where-Object { $_.Value } | Select-Object @{N = 'Column'; E = { $C } }, Value
}
}
} }
catch { elseif ($Path) {
throw "Failed creating property names: $_" ; return $Paths = $Path
} }
} else {
foreach ($Path in $Paths) { $Paths = ''
if ($path) {
$extension = [System.IO.Path]::GetExtension($Path)
if ($extension -notmatch '.xlsx$|.xlsm$') {
throw "Import-Excel does not support reading this extension type $($extension)"
}
$resolvedPath = (Resolve-Path $Path -ErrorAction SilentlyContinue)
if ($resolvedPath) {
$Path = $resolvedPath.ProviderPath
}
else {
throw "'$($Path)' file not found"
}
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path, 'Open', 'Read', 'ReadWrite'
$ExcelPackage = New-Object -TypeName OfficeOpenXml.ExcelPackage
if ($Password) { $ExcelPackage.Load($stream, $Password) }
else { $ExcelPackage.Load($stream) }
} }
try { function Get-PropertyNames {
#Select worksheet <#
if (-not $WorksheetName) { $Worksheet = $ExcelPackage.Workbook.Worksheets[1] } .SYNOPSIS
elseif (-not ($Worksheet = $ExcelPackage.Workbook.Worksheets[$WorkSheetName])) { Create objects containing the column number and the column name for each of the different header types.
throw "Worksheet '$WorksheetName' not found, the workbook only contains the worksheets '$($ExcelPackage.Workbook.Worksheets)'. If you only wish to select the first worksheet, please remove the '-WorksheetName' parameter." ; return #>
} [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = "Name would be incorrect, and command is not exported")]
param(
[Parameter(Mandatory)]
[Int[]]$Columns,
[Parameter(Mandatory)]
[Int]$StartRow
)
Write-Debug $sw.Elapsed.TotalMilliseconds try {
#region Get rows and columns if ($HeaderName) {
#If we are doing dataonly it is quicker to work out which rows to ignore before processing the cells. $i = 0
if (-not $EndRow ) { $EndRow = $Worksheet.Dimension.End.Row } foreach ($H in $HeaderName) {
if (-not $EndColumn) { $EndColumn = $Worksheet.Dimension.End.Column } $H | Select-Object @{N = 'Column'; E = { $Columns[$i] } }, @{N = 'Value'; E = { $H } }
$endAddress = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$EndRow]C[$EndColumn]", 0, 0) $i++
if ($DataOnly) {
#If we are using headers startrow will be the header-row so examine data from startRow + 1,
if ($NoHeader) { $range = "A" + ($StartRow ) + ":" + $endAddress }
else { $range = "A" + ($StartRow + 1 ) + ":" + $endAddress }
#We're going to look at every cell and build 2 hash tables holding rows & columns which contain data.
#Want to Avoid 'select unique' operations & large Sorts, becuse time time taken increases with square
#of number of items (PS uses heapsort at large size). Instead keep a list of what we have seen,
#using Hash tables: "we've seen it" is all we need, no need to worry about "seen it before" / "Seen it many times".
$colHash = @{ }
$rowHash = @{ }
foreach ($cell in $Worksheet.Cells[$range]) {
if ($null -ne $cell.Value ) { $colHash[$cell.Start.Column] = 1; $rowHash[$cell.Start.row] = 1 }
}
$rows = ( $StartRow..$EndRow ).Where( { $rowHash[$_] })
$columns = ($StartColumn..$EndColumn).Where( { $colHash[$_] })
}
else {
$Columns = $StartColumn .. $EndColumn ; if ($StartColumn -gt $EndColumn) { Write-Warning -Message "Selecting columns $StartColumn to $EndColumn might give odd results." }
if ($NoHeader) { $Rows = $StartRow..$EndRow ; if ($StartRow -gt $EndRow) { Write-Warning -Message "Selecting rows $StartRow to $EndRow might give odd results." } }
elseif ($HeaderName) { $Rows = $StartRow..$EndRow }
else { $Rows = (1 + $StartRow)..$EndRow } # ; if ($StartRow -ge $EndRow) { Write-Warning -Message "Selecting $StartRow as the header with data in $(1+$StartRow) to $EndRow might give odd results." } }
}
#endregion
#region Create property names
if ((-not $Columns) -or (-not ($PropertyNames = Get-PropertyNames -Columns $Columns -StartRow $StartRow))) {
throw "No column headers found on top row '$StartRow'. If column headers in the worksheet are not a requirement then please use the '-NoHeader' or '-HeaderName' parameter."; return
}
if ($Duplicates = $PropertyNames | Group-Object Value | Where-Object Count -GE 2) {
throw "Duplicate column headers found on row '$StartRow' in columns '$($Duplicates.Group.Column)'. Column headers must be unique, if this is not a requirement please use the '-NoHeader' or '-HeaderName' parameter."; return
}
#endregion
Write-Debug $sw.Elapsed.TotalMilliseconds
if (-not $Rows) {
Write-Warning "Worksheet '$WorksheetName' in workbook '$Path' contains no data in the rows after top row '$StartRow'"
}
else {
#region Create one object per row
if ($AsText) {
<#join items in AsText together with ~~~ . Escape any regex special characters...
# which turns "*" into "\*" make it ".*". Convert ~~~ to $|^ and top and tail with ^%;
So if we get "Week", "[Time]" and "*date*" ; make the expression ^week$|^\[Time\]$|^.*Date.*$
$make a regex for this which is case insensitive (option 1) and compiled (option 8)
#>
$TextColExpression = "^" + [regex]::Escape($AsText -join "~~~").replace("\*", ".*").replace("~~~", "$|^") + "$"
$TextColRegEx = New-Object -TypeName regex -ArgumentList $TextColExpression , 9
}
foreach ($R in $Rows) {
#Disabled write-verbose for speed
# Write-Verbose "Import row '$R'"
$NewRow = [Ordered]@{ }
if ($TextColRegEx) {
foreach ($P in $PropertyNames) {
if ($TextColRegEx.IsMatch($P.Value)) {
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Text
}
else { $NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value }
}
} }
}
elseif ($NoHeader) {
$i = 0
foreach ($C in $Columns) {
$i++
$C | Select-Object @{N = 'Column'; E = { $_ } }, @{N = 'Value'; E = { 'P' + $i } }
}
}
else {
if ($StartRow -lt 1) {
throw 'The top row can never be less than 1 when we need to retrieve headers from the worksheet.' ; return
}
foreach ($C in $Columns) {
#allow "False" or "0" to be column headings
$Worksheet.Cells[$StartRow, $C] | Where-Object {-not [string]::IsNullOrEmpty($_.Value) } | Select-Object @{N = 'Column'; E = { $C } }, Value
}
}
}
catch {
throw "Failed creating property names: $_" ; return
}
}
foreach ($Path in $Paths) {
if ($path) {
$extension = [System.IO.Path]::GetExtension($Path)
if ($extension -notmatch '.xlsx$|.xlsm$') {
throw "Import-Excel does not support reading this extension type $($extension)"
}
$resolvedPath = (Resolve-Path $Path -ErrorAction SilentlyContinue)
if ($resolvedPath) {
$Path = $resolvedPath.ProviderPath
}
else {
throw "'$($Path)' file not found"
}
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path, 'Open', 'Read', 'ReadWrite'
$ExcelPackage = New-Object -TypeName OfficeOpenXml.ExcelPackage
if ($Password) { $ExcelPackage.Load($stream, $Password) }
else { $ExcelPackage.Load($stream) }
}
try {
#Select worksheet
if (-not $WorksheetName) { $Worksheet = $ExcelPackage.Workbook.Worksheets[1] }
elseif (-not ($Worksheet = $ExcelPackage.Workbook.Worksheets[$WorkSheetName])) {
throw "Worksheet '$WorksheetName' not found, the workbook only contains the worksheets '$($ExcelPackage.Workbook.Worksheets)'. If you only wish to select the first worksheet, please remove the '-WorksheetName' parameter." ; return
}
#region Get rows and columns
#If we are doing dataonly it is quicker to work out which rows to ignore before processing the cells.
if (-not $EndRow ) { $EndRow = $Worksheet.Dimension.End.Row }
if (-not $EndColumn) { $EndColumn = $Worksheet.Dimension.End.Column }
$endAddress = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$EndRow]C[$EndColumn]", 0, 0)
if ($DataOnly) {
#If we are using headers startrow will be the header-row so examine data from startRow + 1,
if ($NoHeader) { $range = "A" + ($StartRow ) + ":" + $endAddress }
else { $range = "A" + ($StartRow + 1 ) + ":" + $endAddress }
#We're going to look at every cell and build 2 hash tables holding rows & columns which contain data.
#Want to Avoid 'select unique' operations & large Sorts, becuse time time taken increases with square
#of number of items (PS uses heapsort at large size). Instead keep a list of what we have seen,
#using Hash tables: "we've seen it" is all we need, no need to worry about "seen it before" / "Seen it many times".
$colHash = @{ }
$rowHash = @{ }
foreach ($cell in $Worksheet.Cells[$range]) {
if ($null -ne $cell.Value ) { $colHash[$cell.Start.Column] = 1; $rowHash[$cell.Start.row] = 1 }
}
$rows = ( $StartRow..$EndRow ).Where( { $rowHash[$_] })
$columns = ($StartColumn..$EndColumn).Where( { $colHash[$_] })
}
else {
$Columns = $StartColumn .. $EndColumn ; if ($StartColumn -gt $EndColumn) { Write-Warning -Message "Selecting columns $StartColumn to $EndColumn might give odd results." }
if ($NoHeader) { $Rows = $StartRow..$EndRow ; if ($StartRow -gt $EndRow) { Write-Warning -Message "Selecting rows $StartRow to $EndRow might give odd results." } }
elseif ($HeaderName) { $Rows = $StartRow..$EndRow }
else { else {
foreach ($P in $PropertyNames) { $Rows = (1 + $StartRow)..$EndRow
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value if ($StartRow -eq 1 -and $EndRow -eq 1) {
# Write-Verbose "Import cell '$($Worksheet.Cells[$R, $P.Column].Address)' with property name '$($p.Value)' and value '$($Worksheet.Cells[$R, $P.Column].Value)'." $Rows = 0
} }
} }
[PSCustomObject]$NewRow
# ; if ($StartRow -ge $EndRow) { Write-Warning -Message "Selecting $StartRow as the header with data in $(1+$StartRow) to $EndRow might give odd results." } }
} }
#endregion #endregion
#region Create property names
if ((-not $Columns) -or (-not ($PropertyNames = Get-PropertyNames -Columns $Columns -StartRow $StartRow))) {
throw "No column headers found on top row '$StartRow'. If column headers in the worksheet are not a requirement then please use the '-NoHeader' or '-HeaderName' parameter."; return
}
if ($Duplicates = $PropertyNames | Group-Object Value | Where-Object Count -GE 2) {
throw "Duplicate column headers found on row '$StartRow' in columns '$($Duplicates.Group.Column)'. Column headers must be unique, if this is not a requirement please use the '-NoHeader' or '-HeaderName' parameter."; return
}
#endregion
if (-not $Rows) {
Write-Warning "Worksheet '$WorksheetName' in workbook '$Path' contains no data in the rows after top row '$StartRow'"
}
else {
#region Create one object per row
if ($AsText -or $AsDate) {
<#join items in AsText together with ~~~ . Escape any regex special characters...
# which turns "*" into "\*" make it ".*". Convert ~~~ to $|^ and top and tail with ^%;
So if we get "Week", "[Time]" and "*date*" ; make the expression ^week$|^\[Time\]$|^.*Date.*$
$make a regex for this which is case insensitive (option 1) and compiled (option 8)
#>
$TextColExpression = ''
if ($AsText) {
$TextColExpression += '(?<astext>^' + [regex]::Escape($AsText -join '~~~').replace('\*', '.*').replace('~~~', '$|^') + '$)'
}
if ($AsText -and $AsDate) {
$TextColExpression += "|"
}
if ($AsDate) {
$TextColExpression += '(?<asDate>^' + [regex]::Escape($AsDate -join '~~~').replace('\*', '.*').replace('~~~', '$|^') + '$)'
}
$TextColRegEx = New-Object -TypeName regex -ArgumentList $TextColExpression , 9
}
else {$TextColRegEx = $null}
foreach ($R in $Rows) {
#Disabled write-verbose for speed
# Write-Verbose "Import row '$R'"
$NewRow = [Ordered]@{ }
if ($TextColRegEx) {
foreach ($P in $PropertyNames) {
$MatchTest = $TextColRegEx.Match($P.value)
if ($MatchTest.groups.name -eq "astext") {
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Text
}
elseif ($MatchTest.groups.name -eq "asdate" -and $Worksheet.Cells[$R, $P.Column].Value -is [System.ValueType]) {
$NewRow[$P.Value] = [datetime]::FromOADate(($Worksheet.Cells[$R, $P.Column].Value))
}
else { $NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value }
}
}
else {
foreach ($P in $PropertyNames) {
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value
# Write-Verbose "Import cell '$($Worksheet.Cells[$R, $P.Column].Address)' with property name '$($p.Value)' and value '$($Worksheet.Cells[$R, $P.Column].Value)'."
}
}
[PSCustomObject]$NewRow
}
#endregion
}
}
catch { throw "Failed importing the Excel workbook '$Path' with worksheet '$Worksheetname': $_"; return }
finally {
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
} }
Write-Debug $sw.Elapsed.TotalMilliseconds
}
catch { throw "Failed importing the Excel workbook '$Path' with worksheet '$Worksheetname': $_"; return }
finally {
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
} }
} }
}
} }

View File

@@ -1,4 +1,4 @@
function Merge-MultipleSheets { function Merge-MultipleSheets {
[CmdletBinding()] [CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification="False positives when initializing variable in begin block")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification="False positives when initializing variable in begin block")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification="MultipleSheet would be incorrect")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification="MultipleSheet would be incorrect")]

View File

@@ -118,7 +118,7 @@
$headings = $DifferenceObject[0].psobject.Properties.Name # This preserves the sequence - using Get-member would sort them alphabetically! There may be extra properties in $headings = $DifferenceObject[0].psobject.Properties.Name # This preserves the sequence - using Get-member would sort them alphabetically! There may be extra properties in
if ($NoHeader -and "Name" -eq $Key) {$Key = "p1"} if ($NoHeader -and "Name" -eq $Key) {$Key = "p1"}
if ($headings -notcontains $Key -and if ($headings -notcontains $Key -and
('*' -ne $Key)) {Write-Warning -Message "You need to specify one of the headings in the sheet '$Worksheet1' as a key." ; return } ('*' -ne $Key)) {Write-Warning -Message "You need to specify one of the headings in the sheet '$Worksheet2' as a key." ; return }
foreach ($p in $Property) { $propList += ($headings.where({$_ -like $p}) )} foreach ($p in $Property) { $propList += ($headings.where({$_ -like $p}) )}
foreach ($p in $ExcludeProperty) { $propList = $propList.where({$_ -notlike $p}) } foreach ($p in $ExcludeProperty) { $propList = $propList.where({$_ -notlike $p}) }
if (($propList -notcontains $Key) -and if (($propList -notcontains $Key) -and

View File

@@ -39,6 +39,7 @@ function New-ExcelStyle {
[Switch]$AutoSize, [Switch]$AutoSize,
[float]$Width, [float]$Width,
[float]$Height, [float]$Height,
[Alias('Hide')]
[Switch]$Hidden, [Switch]$Hidden,
[Switch]$Locked, [Switch]$Locked,
[Switch]$Merge [Switch]$Merge

View File

@@ -62,6 +62,9 @@ function New-PivotTableDefinition {
$parameters.Remove('NoTotalsInPivot') $parameters.Remove('NoTotalsInPivot')
$parameters["PivotTotals"] = "None" $parameters["PivotTotals"] = "None"
} }
if ($PSBoundParameters.ContainsKey('ChartType') -and -not $PSBoundParameters.ContainsKey('IncludePivotChart')) {
$parameters['IncludePivotChart'] = $true
}
$parameters.Remove('PivotTableName') $parameters.Remove('PivotTableName')
if ($PivotChartDefinition) { if ($PivotChartDefinition) {
$parameters.PivotChartDefinition.XRange = $null $parameters.PivotChartDefinition.XRange = $null

View File

@@ -43,6 +43,7 @@
[Switch]$AutoSize, [Switch]$AutoSize,
[float]$Width, [float]$Width,
[Switch]$AutoNameRange, [Switch]$AutoNameRange,
[Alias('Hidden')]
[Switch]$Hide, [Switch]$Hide,
[Switch]$Specified, [Switch]$Specified,
[Switch]$PassThru [Switch]$PassThru

View File

@@ -42,6 +42,7 @@
[Switch]$AutoSize, [Switch]$AutoSize,
[float]$Width, [float]$Width,
[float]$Height, [float]$Height,
[Alias('Hide')]
[Switch]$Hidden, [Switch]$Hidden,
[Switch]$Locked, [Switch]$Locked,
[Switch]$Merge [Switch]$Merge

View File

@@ -45,6 +45,7 @@
[ValidateRange(-90, 90)] [ValidateRange(-90, 90)]
[int]$TextRotation , [int]$TextRotation ,
[float]$Height, [float]$Height,
[Alias('Hidden')]
[Switch]$Hide, [Switch]$Hide,
[Switch]$ReturnRange, [Switch]$ReturnRange,
[Switch]$PassThru [Switch]$PassThru

View File

@@ -60,6 +60,27 @@ Plus, wiring the [PowerShell ScriptAnalyzer Excel report](https://github.com/dfi
![](./images/ScriptAnalyzerReport.png) ![](./images/ScriptAnalyzerReport.png)
# What's new 7.1.0
Fixes, Updates and new Examples
### Fixed
- Odd behavior on the return of Import-Excel function https://github.com/dfinke/ImportExcel/issues/792
- Export-Excel -FreezeTopRow with -Title https://github.com/dfinke/ImportExcel/issues/795
- Not importing when first row contains a 0 in a column https://github.com/dfinke/ImportExcel/issues/802
### Updated
- Add `-AsDate` support to `Import-Excel` and `ConvertFrom-ExcelSheet`
### New Examples
|PS1|Description|Link|
|---|---|---|
|Pester-To-XLSx|Runs Pester, collects the results, enriches it, and exports it to Excel|[Pester-To-XLSx.ps1](https://github.com/dfinke/ImportExcel/blob/fe68ddbb0dd86e9fd1f3bfe01c4d2b9ce5509510/Examples/Pester-To-XLSx.ps1)
|DSUM|Sums up the numbers in a field (column) of records in a list or database that match conditions that you specify.|[DSUM.ps1](https://github.com/dfinke/ImportExcel/blob/12fa49e3142af2178ae1c6b18d8c757af0d629ac/Examples/ExcelBuiltIns/DSUM.ps1)
|VLookup|Setups up a sheet, you enter the name of an item and the amount is looked up|[VLOOKUP.ps1](https://github.com/dfinke/ImportExcel/blob/e42f42fde92ca636af22252b753a8329f48e15f1/Examples/ExcelBuiltIns/VLOOKUP.ps1)
# What's new 7.0.1 # What's new 7.0.1
More infrastructure improvements. More infrastructure improvements.

View File

@@ -32,7 +32,7 @@ South,avocado,73
$excel = Open-ExcelPackage -Path $xlfile $excel = Open-ExcelPackage -Path $xlfile
$ws = $excel.Workbook.Worksheets["Sheet1"] $ws = $excel.Workbook.Worksheets["Sheet1"]
$ws.Drawings[0].Series.TrendLines.Type | Should Be 'Linear' $ws.Drawings[0].Series.TrendLines.Type | Should -Be 'Linear'
Close-ExcelPackage $excel Close-ExcelPackage $excel
} }
@@ -45,7 +45,7 @@ South,avocado,73
$excel = Open-ExcelPackage -Path $xlfile $excel = Open-ExcelPackage -Path $xlfile
$ws = $excel.Workbook.Worksheets["Sheet1"] $ws = $excel.Workbook.Worksheets["Sheet1"]
$ws.Drawings[0].Series.TrendLines.Type | Should Be 'MovingAvgerage' $ws.Drawings[0].Series.TrendLines.Type | Should -Be 'MovingAvgerage'
Close-ExcelPackage $excel Close-ExcelPackage $excel
} }

View File

@@ -31,29 +31,29 @@ Describe "Compare Worksheet" {
} }
Context "Simple comparison output" { Context "Simple comparison output" {
it "Found the right number of differences " { it "Found the right number of differences " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp.Count | should be 4 $comp.Count | Should -Be 4
} }
it "Found the data row with a changed property " { it "Found the data row with a changed property " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp[0]._Side | should not be $comp[1]._Side $comp[0]._Side | Should -Not -Be $comp[1]._Side
$comp[0]._Row | should be 4 $comp[0]._Row | Should -Be 4
$comp[1]._Row | should be 4 $comp[1]._Row | Should -Be 4
$comp[1].Name | should be $comp[0].Name $comp[1].Name | Should -Be $comp[0].Name
$comp[0].DisplayName | should be $row4Displayname $comp[0].DisplayName | Should -Be $row4Displayname
$comp[1].DisplayName | should be "Changed from the orginal" $comp[1].DisplayName | Should -Be "Changed from the orginal"
} }
it "Found the inserted data row " { it "Found the inserted data row " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp[2]._Side | should be '=>' $comp[2]._Side | Should -Be '=>'
$comp[2]._Row | should be 5 $comp[2]._Row | Should -Be 5
$comp[2].Name | should be "Dummy" $comp[2].Name | Should -Be "Dummy"
} }
it "Found the deleted data row " { it "Found the deleted data row " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp[3]._Side | should be '<=' $comp[3]._Side | Should -Be '<='
$comp[3]._Row | should be 6 $comp[3]._Row | Should -Be 6
$comp[3].Name | should be $row6Name $comp[3].Name | Should -Be $row6Name
} }
} }
@@ -75,16 +75,16 @@ Describe "Compare Worksheet" {
$s2Sheet = $xl2.Workbook.Worksheets[1] $s2Sheet = $xl2.Workbook.Worksheets[1]
} }
it "Set the background on the right rows " { it "Set the background on the right rows " {
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
} }
it "Didn't set other cells " { it "Didn't set other cells " {
$s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | should not be "FF90EE90" $s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FF90EE90"
$s1Sheet.Cells["F4"].Style.Font.Color.Rgb | should beNullOrEmpty $s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | should beNullOrEmpty $s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | should not be "FF90EE90" $s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FF90EE90"
} }
AfterAll { AfterAll {
Close-ExcelPackage -ExcelPackage $xl1 -NoSave Close-ExcelPackage -ExcelPackage $xl1 -NoSave
@@ -101,18 +101,18 @@ Describe "Compare Worksheet" {
$s2Sheet = $xl2.Workbook.Worksheets[1] $s2Sheet = $xl2.Workbook.Worksheets[1]
} }
it "Added foreground colour to the right cells " { it "Added foreground colour to the right cells " {
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90" $s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
# $s1Sheet.Cells["F4"].Style.Font.Color.Rgb | should be "FF8B0000" # $s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -Be "FF8B0000"
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | should be "FF8B0000" $s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -Be "FF8B0000"
} }
it "Didn't set the foreground on other cells " { it "Didn't set the foreground on other cells " {
$s1Sheet.Cells["F5"].Style.Font.Color.Rgb | should beNullOrEmpty $s1Sheet.Cells["F5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s2Sheet.Cells["F5"].Style.Font.Color.Rgb | should beNullOrEmpty $s2Sheet.Cells["F5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s1Sheet.Cells["G4"].Style.Font.Color.Rgb | should beNullOrEmpty $s1Sheet.Cells["G4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s2Sheet.Cells["G4"].Style.Font.Color.Rgb | should beNullOrEmpty $s2Sheet.Cells["G4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
} }
AfterAll { AfterAll {
@@ -146,46 +146,46 @@ Describe "Compare Worksheet" {
$s2Sheet = $xl2.Workbook.Worksheets["server2"] $s2Sheet = $xl2.Workbook.Worksheets["server2"]
} }
it "Found the right number of differences " { it "Found the right number of differences " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp.Count | should be 4 $comp.Count | Should -Be 4
} }
it "Found the data row with a changed property " { it "Found the data row with a changed property " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp[0]._Side | should not be $comp[1]._Side $comp[0]._Side | Should -Not -Be $comp[1]._Side
$comp[0]._Row | should be 4 $comp[0]._Row | Should -Be 4
$comp[1]._Row | should be 4 $comp[1]._Row | Should -Be 4
$comp[1].ServiceName | should be $comp[0].ServiceName $comp[1].ServiceName | Should -Be $comp[0].ServiceName
$comp[0].DisplayName | should be $row4Displayname $comp[0].DisplayName | Should -Be $row4Displayname
$comp[1].DisplayName | should be "Changed from the orginal" $comp[1].DisplayName | Should -Be "Changed from the orginal"
} }
it "Found the inserted data row " { it "Found the inserted data row " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp[2]._Side | should be '=>' $comp[2]._Side | Should -Be '=>'
$comp[2]._Row | should be 5 $comp[2]._Row | Should -Be 5
$comp[2].ServiceName | should be "Dummy" $comp[2].ServiceName | Should -Be "Dummy"
} }
it "Found the deleted data row " { it "Found the deleted data row " {
$comp | should not beNullOrEmpty $comp | Should -Not -BeNullOrEmpty
$comp[3]._Side | should be '<=' $comp[3]._Side | Should -Be '<='
$comp[3]._Row | should be 6 $comp[3]._Row | Should -Be 6
$comp[3].ServiceName | should be $row6Name $comp[3].ServiceName | Should -Be $row6Name
} }
it "Set the background on the right rows " { it "Set the background on the right rows " {
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FFFFFFFF" $s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should be "FFFFFFFF" $s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should be "FFFFFFFF" $s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should be "FFFFFFFF" $s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
$s1Sheet.Cells["E4"].Style.Font.Color.Rgb | Should be "FFFF0000" $s1Sheet.Cells["E4"].Style.Font.Color.Rgb | Should -Be "FFFF0000"
$s2Sheet.Cells["E4"].Style.Font.Color.Rgb | Should be "FFFF0000" $s2Sheet.Cells["E4"].Style.Font.Color.Rgb | Should -Be "FFFF0000"
} }
it "Didn't set other cells " { it "Didn't set other cells " {
$s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should not be "FFFFFFFF" $s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FFFFFFFF"
$s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should not be "FFFFFFFF" $s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FFFFFFFF"
$s1Sheet.Cells["E5"].Style.Font.Color.Rgb | Should beNullOrEmpty $s1Sheet.Cells["E5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s2Sheet.Cells["E5"].Style.Font.Color.Rgb | Should beNullOrEmpty $s2Sheet.Cells["E5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should beNullOrEmpty $s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should beNullOrEmpty $s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
} }
AfterAll { AfterAll {
Close-ExcelPackage -ExcelPackage $xl1 -NoSave # -Show Close-ExcelPackage -ExcelPackage $xl1 -NoSave # -Show
@@ -219,44 +219,44 @@ Describe "Merge Worksheet" {
} }
Context "Merge with 3 properties" { Context "Merge with 3 properties" {
it "Created a worksheet with the correct headings " { it "Created a worksheet with the correct headings " {
$ws | should not beNullOrEmpty $ws | Should -Not -BeNullOrEmpty
$ws.Cells[ 1,1].Value | Should be "name" $ws.Cells[ 1,1].Value | Should -Be "name"
$ws.Cells[ 1,2].Value | Should be "DisplayName" $ws.Cells[ 1,2].Value | Should -Be "DisplayName"
$ws.Cells[ 1,3].Value | Should be "StartType" $ws.Cells[ 1,3].Value | Should -Be "StartType"
$ws.Cells[ 1,4].Value | Should be "server2 DisplayName" $ws.Cells[ 1,4].Value | Should -Be "server2 DisplayName"
$ws.Cells[ 1,5].Value | Should be "server2 StartType" $ws.Cells[ 1,5].Value | Should -Be "server2 StartType"
} }
it "Joined the two sheets correctly " { it "Joined the two sheets correctly " {
$ws.Cells[ 2,2].Value | Should be $ws.Cells[ 2,4].Value $ws.Cells[ 2,2].Value | Should -Be $ws.Cells[ 2,4].Value
$ws.Cells[ 2,3].Value | Should be $ws.Cells[ 2,5].Value $ws.Cells[ 2,3].Value | Should -Be $ws.Cells[ 2,5].Value
$ws.cells[ 4,4].value | Should be "Changed from the orginal" $ws.cells[ 4,4].value | Should -Be "Changed from the orginal"
$ws.cells[ 5,1].value | Should be "Dummy" $ws.cells[ 5,1].value | Should -Be "Dummy"
$ws.cells[ 5,2].value | Should beNullOrEmpty $ws.cells[ 5,2].value | Should -BeNullOrEmpty
$ws.cells[ 5,3].value | Should beNullOrEmpty $ws.cells[ 5,3].value | Should -BeNullOrEmpty
$ws.cells[ 5,4].value | Should be "Dummy Service" $ws.cells[ 5,4].value | Should -Be "Dummy Service"
$ws.cells[ 7,4].value | Should beNullOrEmpty $ws.cells[ 7,4].value | Should -BeNullOrEmpty
$ws.cells[ 7,5].value | Should beNullOrEmpty $ws.cells[ 7,5].value | Should -BeNullOrEmpty
$ws.Cells[12,2].Value | Should be $ws.Cells[12,4].Value $ws.Cells[12,2].Value | Should -Be $ws.Cells[12,4].Value
$ws.Cells[12,3].Value | Should be $ws.Cells[12,5].Value $ws.Cells[12,3].Value | Should -Be $ws.Cells[12,5].Value
} }
it "Highlighted the keys in the added / deleted / changed rows " { it "Highlighted the keys in the added / deleted / changed rows " {
$ws.cells[4,1].Style.font.color.rgb | Should be "FF8b0000" $ws.cells[4,1].Style.font.color.rgb | Should -Be "FF8b0000"
$ws.cells[5,1].Style.font.color.rgb | Should be "FF8b0000" $ws.cells[5,1].Style.font.color.rgb | Should -Be "FF8b0000"
$ws.cells[7,1].Style.font.color.rgb | Should be "FF8b0000" $ws.cells[7,1].Style.font.color.rgb | Should -Be "FF8b0000"
} }
it "Set the background for the added / deleted / changed rows " { it "Set the background for the added / deleted / changed rows " {
$ws.cells["A3:E3"].style.Fill.BackgroundColor.Rgb | Should beNullOrEmpty $ws.cells["A3:E3"].style.Fill.BackgroundColor.Rgb | Should -BeNullOrEmpty
$ws.cells["A4:E4"].style.Fill.BackgroundColor.Rgb | Should be "FFFFA500" $ws.cells["A4:E4"].style.Fill.BackgroundColor.Rgb | Should -Be "FFFFA500"
$ws.cells["A5" ].style.Fill.BackgroundColor.Rgb | Should be "FF98FB98" $ws.cells["A5" ].style.Fill.BackgroundColor.Rgb | Should -Be "FF98FB98"
$ws.cells["B5:C5"].style.Fill.BackgroundColor.rgb | Should beNullOrEmpty $ws.cells["B5:C5"].style.Fill.BackgroundColor.rgb | Should -BeNullOrEmpty
$ws.cells["D5:E5"].style.Fill.BackgroundColor.Rgb | Should be "FF98FB98" $ws.cells["D5:E5"].style.Fill.BackgroundColor.Rgb | Should -Be "FF98FB98"
$ws.cells["A7:C7"].style.Fill.BackgroundColor.Rgb | Should be "FFFFB6C1" $ws.cells["A7:C7"].style.Fill.BackgroundColor.Rgb | Should -Be "FFFFB6C1"
$ws.cells["D7:E7"].style.Fill.BackgroundColor.rgb | Should beNullOrEmpty $ws.cells["D7:E7"].style.Fill.BackgroundColor.rgb | Should -BeNullOrEmpty
} }
} }
Context "Wider data set" { Context "Wider data set" {
it "Coped with columns beyond Z in the Output sheet " { it "Coped with columns beyond Z in the Output sheet " {
{ Merge-Worksheet -Referencefile "TestDrive:\server1.xlsx" -Differencefile "TestDrive:\server2.xlsx" -OutputFile "TestDrive:\combined2.xlsx" } | Should not throw { Merge-Worksheet -Referencefile "TestDrive:\server1.xlsx" -Differencefile "TestDrive:\server2.xlsx" -OutputFile "TestDrive:\combined2.xlsx" } | Should -Not -Throw
} }
} }
} }
@@ -296,64 +296,64 @@ Describe "Merge Multiple sheets" {
} }
it "Created a worksheet with the correct headings " { it "Created a worksheet with the correct headings " {
$ws | Should not beNullOrEmpty $ws | Should -Not -BeNullOrEmpty
$ws.Cells[ 1,2 ].Value | Should be "name" $ws.Cells[ 1,2 ].Value | Should -Be "name"
$ws.Cells[ 1,3 ].Value | Should be "server1 DisplayName" $ws.Cells[ 1,3 ].Value | Should -Be "server1 DisplayName"
$ws.Cells[ 1,4 ].Value | Should be "server1 StartType" $ws.Cells[ 1,4 ].Value | Should -Be "server1 StartType"
$ws.Cells[ 1,5 ].Value | Should be "server2 DisplayName" $ws.Cells[ 1,5 ].Value | Should -Be "server2 DisplayName"
$ws.Cells[ 1,6 ].Value | Should be "server2 StartType" $ws.Cells[ 1,6 ].Value | Should -Be "server2 StartType"
$ws.Column(7).hidden | Should be $true $ws.Column(7).hidden | Should -Be $true
$ws.Cells[ 1,8].Value | Should be "server2 Row" $ws.Cells[ 1,8].Value | Should -Be "server2 Row"
$ws.Cells[ 1,9 ].Value | Should be "server3 DisplayName" $ws.Cells[ 1,9 ].Value | Should -Be "server3 DisplayName"
$ws.Cells[ 1,10].Value | Should be "server3 StartType" $ws.Cells[ 1,10].Value | Should -Be "server3 StartType"
$ws.Column(11).hidden | Should be $true $ws.Column(11).hidden | Should -Be $true
$ws.Cells[ 1,12].Value | Should be "server3 Row" $ws.Cells[ 1,12].Value | Should -Be "server3 Row"
} }
it "Joined the three sheets correctly " { it "Joined the three sheets correctly " {
$ws.Cells[ 2,3 ].Value | Should be $ws.Cells[ 2,5 ].Value $ws.Cells[ 2,3 ].Value | Should -Be $ws.Cells[ 2,5 ].Value
$ws.Cells[ 2,4 ].Value | Should be $ws.Cells[ 2,6 ].Value $ws.Cells[ 2,4 ].Value | Should -Be $ws.Cells[ 2,6 ].Value
$ws.Cells[ 2,5 ].Value | Should be $ws.Cells[ 2,9 ].Value $ws.Cells[ 2,5 ].Value | Should -Be $ws.Cells[ 2,9 ].Value
$ws.Cells[ 2,6 ].Value | Should be $ws.Cells[ 2,10].Value $ws.Cells[ 2,6 ].Value | Should -Be $ws.Cells[ 2,10].Value
$ws.cells[ 4,5 ].value | Should be "Changed from the orginal" $ws.cells[ 4,5 ].value | Should -Be "Changed from the orginal"
$ws.cells[ 4,9 ].value | Should be $ws.Cells[ 4,3 ].Value $ws.cells[ 4,9 ].value | Should -Be $ws.Cells[ 4,3 ].Value
$ws.cells[ 5,2 ].value | Should be "Dummy" $ws.cells[ 5,2 ].value | Should -Be "Dummy"
$ws.cells[ 5,3 ].value | Should beNullOrEmpty $ws.cells[ 5,3 ].value | Should -BeNullOrEmpty
$ws.cells[ 5,4 ].value | Should beNullOrEmpty $ws.cells[ 5,4 ].value | Should -BeNullOrEmpty
$ws.cells[ 5,5 ].value | Should be "Dummy Service" $ws.cells[ 5,5 ].value | Should -Be "Dummy Service"
$ws.cells[ 5,8 ].value | Should be ($ws.cells[ 4,1].value +1) $ws.cells[ 5,8 ].value | Should -Be ($ws.cells[ 4,1].value +1)
$ws.cells[ 5,9 ].value | Should be $ws.cells[ 5,5 ].value $ws.cells[ 5,9 ].value | Should -Be $ws.cells[ 5,5 ].value
$ws.cells[ 7,5 ].value | Should beNullOrEmpty $ws.cells[ 7,5 ].value | Should -BeNullOrEmpty
$ws.cells[ 7,6 ].value | Should beNullOrEmpty $ws.cells[ 7,6 ].value | Should -BeNullOrEmpty
$ws.cells[ 7,9 ].value | Should beNullOrEmpty $ws.cells[ 7,9 ].value | Should -BeNullOrEmpty
$ws.cells[ 7,10].value | Should beNullOrEmpty $ws.cells[ 7,10].value | Should -BeNullOrEmpty
$ws.cells[ 8,3 ].value | Should beNullOrEmpty $ws.cells[ 8,3 ].value | Should -BeNullOrEmpty
$ws.cells[ 8,4 ].value | Should beNullOrEmpty $ws.cells[ 8,4 ].value | Should -BeNullOrEmpty
$ws.cells[ 8,5 ].value | Should beNullOrEmpty $ws.cells[ 8,5 ].value | Should -BeNullOrEmpty
$ws.cells[ 8,6 ].value | Should beNullOrEmpty $ws.cells[ 8,6 ].value | Should -BeNullOrEmpty
$ws.cells[11,9 ].value | Should beNullOrEmpty $ws.cells[11,9 ].value | Should -BeNullOrEmpty
$ws.cells[11,10].value | Should beNullOrEmpty $ws.cells[11,10].value | Should -BeNullOrEmpty
$ws.Cells[12,3 ].Value | Should be $ws.Cells[12,5].Value $ws.Cells[12,3 ].Value | Should -Be $ws.Cells[12,5].Value
$ws.Cells[12,4 ].Value | Should be $ws.Cells[12,6].Value $ws.Cells[12,4 ].Value | Should -Be $ws.Cells[12,6].Value
$ws.Cells[12,9 ].Value | Should be $ws.Cells[12,5].Value $ws.Cells[12,9 ].Value | Should -Be $ws.Cells[12,5].Value
$ws.Cells[12,10].Value | Should be $ws.Cells[12,6].Value $ws.Cells[12,10].Value | Should -Be $ws.Cells[12,6].Value
} }
it "Created Conditional formatting rules " { it "Created Conditional formatting rules " {
$cf=$ws.ConditionalFormatting $cf=$ws.ConditionalFormatting
$cf.Count | Should be 17 $cf.Count | Should -Be 17
$cf[16].Address.Address | Should be 'B2:B1048576' $cf[16].Address.Address | Should -Be 'B2:B1048576'
$cf[16].Type | Should be 'Expression' $cf[16].Type | Should -Be 'Expression'
$cf[16].Formula | Should be 'OR(G2<>"Same",K2<>"Same")' $cf[16].Formula | Should -Be 'OR(G2<>"Same",K2<>"Same")'
$cf[16].Style.Font.Color.Color.Name | Should be "FFFF0000" $cf[16].Style.Font.Color.Color.Name | Should -Be "FFFF0000"
$cf[14].Address.Address | Should be 'D2:D1048576' $cf[14].Address.Address | Should -Be 'D2:D1048576'
$cf[14].Type | Should be 'Expression' $cf[14].Type | Should -Be 'Expression'
$cf[14].Formula | Should be 'OR(G2="Added",K2="Added")' $cf[14].Formula | Should -Be 'OR(G2="Added",K2="Added")'
$cf[14].Style.Fill.BackgroundColor.Color.Name | Should be 'ffffb6c1' $cf[14].Style.Fill.BackgroundColor.Color.Name | Should -Be 'ffffb6c1'
$cf[14].Style.Fill.PatternType.ToString() | Should be 'Solid' $cf[14].Style.Fill.PatternType.ToString() | Should -Be 'Solid'
$cf[ 0].Address.Address | Should be 'F1:F1048576' $cf[ 0].Address.Address | Should -Be 'F1:F1048576'
$cf[ 0].Type | Should be 'Expression' $cf[ 0].Type | Should -Be 'Expression'
$cf[ 0].Formula | Should be 'G1="Added"' $cf[ 0].Formula | Should -Be 'G1="Added"'
$cf[ 0].Style.Fill.BackgroundColor.Color.Name | Should be 'ffffa500' $cf[ 0].Style.Fill.BackgroundColor.Color.Name | Should -Be 'ffffa500'
$cf[ 0].Style.Fill.PatternType.ToString() | Should be 'Solid' $cf[ 0].Style.Fill.PatternType.ToString() | Should -Be 'Solid'
} }
} }
} }

View File

@@ -12,25 +12,30 @@ Describe 'ConvertFrom-ExcelSheet / Export-ExcelSheet' {
ConvertFrom-ExcelSheet -Path $dataPath -OutputPath $Outpath -AsText "GridPosition" -Property driver, ConvertFrom-ExcelSheet -Path $dataPath -OutputPath $Outpath -AsText "GridPosition" -Property driver,
@{n="date"; e={[datetime]::FromOADate($_.Date).tostring("#MM/dd/yyyy#")}} , FinishPosition, GridPosition @{n="date"; e={[datetime]::FromOADate($_.Date).tostring("#MM/dd/yyyy#")}} , FinishPosition, GridPosition
$ThirdText = Get-Content (Join-path -Path $Outpath -ChildPath "First10Races.csv") $ThirdText = Get-Content (Join-path -Path $Outpath -ChildPath "First10Races.csv")
ConvertFrom-ExcelSheet -Path $dataPath -OutputPath $Outpath -AsDate "date"
$FourthText = Get-Content (Join-path -Path $Outpath -ChildPath "First10Races.csv")
} }
Context "Exporting to CSV" { Context "Exporting to CSV" {
it "Exported the expected columns to a CSV file " { it "Exported the expected columns to a CSV file " {
$firstText[0] | should be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"' $firstText[0] | Should -Be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
$SecondText[0] | should be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"' $SecondText[0] | Should -Be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
$ThirdText[0] | should be '"Driver","date","FinishPosition","GridPosition"' $ThirdText[0] | Should -Be '"Driver","date","FinishPosition","GridPosition"'
$FourthText[0] | Should -Be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
} }
it "Applied ASText and Properties correctly " { it "Applied AsText, AsDate and Properties correctly " {
$firstText[1] | should match '^"\w+","\d{5}","\d{1,2}","\w+ \w+","[1-9]\d?","\w+","\d{1,2}"$' $firstText[1] | Should -Match '^"\w+","\d{5}","\d{1,2}","\w+ \w+","[1-9]\d?","\w+","\d{1,2}"$'
$date = $firstText[1] -replace '^.*(\d{5}).*$', '$1' $date = $firstText[1] -replace '^.*(\d{5}).*$', '$1'
$date = [datetime]::FromOADate($date).toString("D") $date = [datetime]::FromOADate($date).toString("D")
$secondText[1] | should belike "*$date*" $secondText[1] | Should -Belike "*$date*"
$secondText[1] | should match '"0\d","\w+","\d{1,2}"$' $secondText[1] | Should -Match '"0\d","\w+","\d{1,2}"$'
$ThirdText[1] | should match '^"\w+ \w+","#\d\d/\d\d/\d{4}#","\d","0\d"$' $ThirdText[1] | Should -Match '^"\w+ \w+","#\d\d/\d\d/\d{4}#","\d","0\d"$'
$FourthText[1] | Should -Match '^"\w+","([012]\d/|[1-9]/)'
} }
} }
Context "Export aliased to ConvertFrom" { Context "Export aliased to ConvertFrom" {
it "Applied ASText and Properties correctly " { it "Definded the alias name with " {
(Get-Alias Export-ExcelSheet).source | should be "ImportExcel" (Get-Alias Export-ExcelSheet).source | Should -Be "ImportExcel"
(Get-Alias Export-ExcelSheet).Definition | Should -Be "ConvertFrom-ExcelSheet"
} }
} }
} }

View File

@@ -22,7 +22,7 @@ Describe "ConvertFrom-ExcelToSQLInsert" {
$actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1 $actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1
$actual | should be $expected $actual | Should -Be $expected
} }
It "Should have NULL".PadRight(90) { It "Should have NULL".PadRight(90) {
@@ -30,6 +30,6 @@ Describe "ConvertFrom-ExcelToSQLInsert" {
$actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1 -ConvertEmptyStringsToNull $actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1 -ConvertEmptyStringsToNull
$actual | should be $expected $actual | Should -Be $expected
} }
} }

View File

@@ -41,9 +41,9 @@ Describe "Copy-Worksheet" {
$ws = $excel.Workbook.Worksheets["Processes"] $ws = $excel.Workbook.Worksheets["Processes"]
} }
it "Inserted a worksheet " { it "Inserted a worksheet " {
$Excel.Workbook.Worksheets.count | Should be 2 $Excel.Workbook.Worksheets.count | Should -Be 2
$ws | Should not benullorEmpty $ws | Should -Not -BenullorEmpty
$ws.Dimension.Address | should be $ProcRange $ws.Dimension.Address | Should -Be $ProcRange
} }
} }
Context "Mixed types using a package object" { Context "Mixed types using a package object" {
@@ -54,38 +54,38 @@ Describe "Copy-Worksheet" {
$ws = $Excel.Workbook.Worksheets[3] $ws = $Excel.Workbook.Worksheets[3]
} }
it "Copied a worksheet, giving the expected name, number of rows and number of columns " { it "Copied a worksheet, giving the expected name, number of rows and number of columns " {
$Excel.Workbook.Worksheets.count | Should be 3 $Excel.Workbook.Worksheets.count | Should -Be 3
$ws | Should not benullorEmpty $ws | Should -Not -BenullorEmpty
$ws.Name | Should be "CopyOfMixedTypes" $ws.Name | Should -Be "CopyOfMixedTypes"
$ws.Dimension.Columns | Should be 22 $ws.Dimension.Columns | Should -Be 22
$ws.Dimension.Rows | Should be 2 $ws.Dimension.Rows | Should -Be 2
} }
it "Copied the expected data into the worksheet " { it "Copied the expected data into the worksheet " {
$ws.Cells[2, 1].Value.Gettype().name | Should be 'DateTime' $ws.Cells[2, 1].Value.Gettype().name | Should -Be 'DateTime'
$ws.Cells[2, 2].Formula | Should be 'SUM(F2:G2)' $ws.Cells[2, 2].Formula | Should -Be 'SUM(F2:G2)'
$ws.Cells[2, 5].Value.GetType().name | Should be 'String' $ws.Cells[2, 5].Value.GetType().name | Should -Be 'String'
$ws.Cells[2, 6].Value.GetType().name | Should be 'String' $ws.Cells[2, 6].Value.GetType().name | Should -Be 'String'
$ws.Cells[2, 18].Value.GetType().name | Should be 'String' $ws.Cells[2, 18].Value.GetType().name | Should -Be 'String'
($ws.Cells[2, 11].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 11].Value -is [valuetype] ) | Should -Be $true
($ws.Cells[2, 12].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 12].Value -is [valuetype] ) | Should -Be $true
($ws.Cells[2, 13].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 13].Value -is [valuetype] ) | Should -Be $true
$ws.Cells[2, 11].Value | Should beLessThan 0 $ws.Cells[2, 11].Value | Should -BeLessThan 0
$ws.Cells[2, 12].Value | Should beLessThan 0 $ws.Cells[2, 12].Value | Should -BeLessThan 0
$ws.Cells[2, 13].Value | Should beLessThan 0 $ws.Cells[2, 13].Value | Should -BeLessThan 0
if ((Get-Culture).NumberFormat.NumberGroupSeparator -EQ ",") { if ((Get-Culture).NumberFormat.NumberGroupSeparator -EQ ",") {
($ws.Cells[2, 8].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 8].Value -is [valuetype] ) | Should -Be $true
$ws.Cells[2, 9].Value.GetType().name | Should be 'String' $ws.Cells[2, 9].Value.GetType().name | Should -Be 'String'
} }
elseif ((Get-Culture).NumberFormat.NumberGroupSeparator -EQ ".") { elseif ((Get-Culture).NumberFormat.NumberGroupSeparator -EQ ".") {
($ws.Cells[2, 9].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 9].Value -is [valuetype] ) | Should -Be $true
$ws.Cells[2, 8].Value.GetType().name | Should be 'String' $ws.Cells[2, 8].Value.GetType().name | Should -Be 'String'
} }
($ws.Cells[2, 14].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 14].Value -is [valuetype] ) | Should -Be $true
$ws.Cells[2, 15].Value.GetType().name | Should be 'String' $ws.Cells[2, 15].Value.GetType().name | Should -Be 'String'
$ws.Cells[2, 16].Value.GetType().name | Should be 'String' $ws.Cells[2, 16].Value.GetType().name | Should -Be 'String'
$ws.Cells[2, 17].Value.GetType().name | Should be 'String' $ws.Cells[2, 17].Value.GetType().name | Should -Be 'String'
($ws.Cells[2, 19].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 19].Value -is [valuetype] ) | Should -Be $true
($ws.Cells[2, 20].Value -is [valuetype] ) | Should be $true ($ws.Cells[2, 20].Value -is [valuetype] ) | Should -Be $true
} }
} }
@@ -113,7 +113,7 @@ Describe "Copy-Worksheet" {
$targetSheets | ForEach-Object { Remove-Worksheet -FullName $xlfile -WorksheetName $_ } $targetSheets | ForEach-Object { Remove-Worksheet -FullName $xlfile -WorksheetName $_ }
(Get-ExcelSheetInfo -Path $xlfile ).Count | Should Be 3 (Get-ExcelSheetInfo -Path $xlfile ).Count | Should -Be 3
} }
} }
@@ -136,8 +136,8 @@ Describe "Copy-Worksheet" {
} }
it "Should copy sheets piped into the command " { it "Should copy sheets piped into the command " {
$excel = Open-ExcelPackage $xlfileArchive $excel = Open-ExcelPackage $xlfileArchive
$excel.Workbook.Worksheets.Count | should be 5 $excel.Workbook.Worksheets.Count | should -be 5
$excel.Workbook.Worksheets['1.3.2019'].Cells['A1'].Value | should be 'Hello World' $excel.Workbook.Worksheets['1.3.2019'].Cells['A1'].Value | should -be 'Hello World'
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -22,45 +22,45 @@ Apple, New York, 1200,700
$ws2 = $excel.Workbook.Worksheets[2] $ws2 = $excel.Workbook.Worksheets[2]
Context "Data Page" { Context "Data Page" {
It "Inserted the data and created the table " { It "Inserted the data and created the table " {
$ws1.Tables[0] | Should not beNullOrEmpty $ws1.Tables[0] | Should -Not -BeNullOrEmpty
$ws1.Tables[0].Address.Address | Should be "A1:D7" $ws1.Tables[0].Address.Address | Should -Be "A1:D7"
$ws1.Tables[0].StyleName | Should be "TableStyleMedium13" $ws1.Tables[0].StyleName | Should -Be "TableStyleMedium13"
} }
It "Applied conditional formatting " { It "Applied conditional formatting " {
$ws1.ConditionalFormatting[0] | Should not beNullOrEmpty $ws1.ConditionalFormatting[0] | Should -Not -BeNullOrEmpty
$ws1.ConditionalFormatting[0].type.ToString() | Should be "DataBar" $ws1.ConditionalFormatting[0].type.ToString() | Should -Be "DataBar"
$ws1.ConditionalFormatting[0].Color.G | Should beGreaterThan 100 $ws1.ConditionalFormatting[0].Color.G | Should -BeGreaterThan 100
$ws1.ConditionalFormatting[0].Color.R | Should beLessThan 100 $ws1.ConditionalFormatting[0].Color.R | Should -BeLessThan 100
$ws1.ConditionalFormatting[0].Address.Address | Should be "C2:C7" $ws1.ConditionalFormatting[0].Address.Address | Should -Be "C2:C7"
} }
It "Added the chart " { It "Added the chart " {
$ws1.Drawings[0] | Should not beNullOrEmpty $ws1.Drawings[0] | Should -Not -BeNullOrEmpty
$ws1.Drawings[0].ChartType.ToString() | Should be "DoughNut" $ws1.Drawings[0].ChartType.ToString() | Should -Be "DoughNut"
$ws1.Drawings[0].Series[0].Series | Should be "'Sheet1'!C2:C7" $ws1.Drawings[0].Series[0].Series | Should -Be "'Sheet1'!C2:C7"
} }
} }
Context "PivotTable" { Context "PivotTable" {
it "Created the PivotTable on a new page " { it "Created the PivotTable on a new page " {
$ws2 | Should not beNullOrEmpty $ws2 | Should -Not -BeNullOrEmpty
$ws2.PivotTables[0] | Should not beNullOrEmpty $ws2.PivotTables[0] | Should -Not -BeNullOrEmpty
$ws2.PivotTables[0].Fields.Count | Should be 4 $ws2.PivotTables[0].Fields.Count | Should -Be 4
$ws2.PivotTables[0].DataFields[0].Format | Should be "$#,##0.00" $ws2.PivotTables[0].DataFields[0].Format | Should -Be "$#,##0.00"
$ws2.PivotTables[0].RowFields[0].Name | Should be "City" $ws2.PivotTables[0].RowFields[0].Name | Should -Be "City"
$ws2.PivotTables[0].ColumnFields[0].Name | Should be "Product" $ws2.PivotTables[0].ColumnFields[0].Name | Should -Be "Product"
$ws2.PivotTables[0].RowGrandTotals | Should be $true $ws2.PivotTables[0].RowGrandTotals | Should -Be $true
$ws2.PivotTables[0].ColumGrandTotals | Should be $true #Epplus's mis-spelling of column not mine $ws2.PivotTables[0].ColumGrandTotals | Should -Be $true #Epplus's mis-spelling of column not mine
} }
it "Made the PivotTable page active " { it "Made the PivotTable page active " {
Set-ItResult -Pending -Because "Bug in EPPLus 4.5" Set-ItResult -Pending -Because "Bug in EPPLus 4.5"
$ws2.View.TabSelected | Should be $true $ws2.View.TabSelected | Should -Be $true
} }
it "Created the Pivot Chart " { it "Created the Pivot Chart " {
$ws2.Drawings[0] | Should not beNullOrEmpty $ws2.Drawings[0] | Should -Not -BeNullOrEmpty
$ws2.Drawings[0].ChartType.ToString() | Should be ColumnClustered $ws2.Drawings[0].ChartType.ToString() | Should -Be ColumnClustered
$ws2.Drawings[0].YAxis.MajorUnit | Should be 500 $ws2.Drawings[0].YAxis.MajorUnit | Should -Be 500
$ws2.Drawings[0].YAxis.MinorUnit | Should be 100 $ws2.Drawings[0].YAxis.MinorUnit | Should -Be 100
$ws2.Drawings[0].YAxis.Format | Should be "$#,##0" $ws2.Drawings[0].YAxis.Format | Should -Be "$#,##0"
$ws2.Drawings[0].Legend.Position.ToString() | Should be "Bottom" $ws2.Drawings[0].Legend.Position.ToString() | Should -Be "Bottom"
} }
} }

View File

@@ -62,84 +62,84 @@ Describe "Creating small named ranges with hyperlinks" {
} }
Context "Creating hyperlinks" { Context "Creating hyperlinks" {
it "Put the data into the sheet and created the expected named ranges " { it "Put the data into the sheet and created the expected named ranges " {
$sheet.Dimension.Rows | should be $expectedRows $sheet.Dimension.Rows | Should -Be $expectedRows
$sheet.Dimension.Columns | should be $columns $sheet.Dimension.Columns | Should -Be $columns
$sheet.Names.Count | should be ($columns + $results.Count) $sheet.Names.Count | Should -Be ($columns + $results.Count)
$sheet.Names[$results[0].Name] | should not benullorEmpty $sheet.Names[$results[0].Name] | Should -Not -BenullorEmpty
$sheet.Names[$results[-1].Name] | should not benullorEmpty $sheet.Names[$results[-1].Name] | Should -Not -BenullorEmpty
} }
it "Added hyperlinks to the named ranges " { it "Added hyperlinks to the named ranges " {
$sheet.cells["a1"].Hyperlink.Display | should match $results[0].Name $sheet.cells["a1"].Hyperlink.Display | Should -Match $results[0].Name
$sheet.cells["a1"].Hyperlink.ReferenceAddress | should match $results[0].Name $sheet.cells["a1"].Hyperlink.ReferenceAddress | Should -Match $results[0].Name
} }
} }
Context "Adding calculated column" { Context "Adding calculated column" {
It "Populated the cells with the right heading and formulas " { It "Populated the cells with the right heading and formulas " {
$sheet.Cells[( $results.Count), $columns] | Should benullorEmpty $sheet.Cells[( $results.Count), $columns] | Should -BenullorEmpty
$sheet.Cells[(1 + $results.Count), $columns].Value | Should be "PlacesGained/Lost" $sheet.Cells[(1 + $results.Count), $columns].Value | Should -Be "PlacesGained/Lost"
$sheet.Cells[(2 + $results.Count), $columns].Formula | should be "GridPosition-FinishPosition" $sheet.Cells[(2 + $results.Count), $columns].Formula | Should -Be "GridPosition-FinishPosition"
$sheet.Names["PlacesGained_Lost"] | should not benullorEmpty $sheet.Names["PlacesGained_Lost"] | Should -Not -BenullorEmpty
} }
It "Performed the calculation " { It "Performed the calculation " {
$placesMade = $Sheet.Cells[(2 + $results.Count), 5].value - $Sheet.Cells[(2 + $results.Count), 3].value $placesMade = $Sheet.Cells[(2 + $results.Count), 5].value - $Sheet.Cells[(2 + $results.Count), 3].value
$sheet.Cells[(2 + $results.Count), $columns].value | Should be $placesmade $sheet.Cells[(2 + $results.Count), $columns].value | Should -Be $placesmade
} }
It "Applied ConditionalFormatting, including StopIfTrue, Priority " { It "Applied ConditionalFormatting, including StopIfTrue, Priority " {
$sheet.ConditionalFormatting[0].Address.Start.Column | should be $columns $sheet.ConditionalFormatting[0].Address.Start.Column | Should -Be $columns
$sheet.ConditionalFormatting[0].Address.End.Column | should be $columns $sheet.ConditionalFormatting[0].Address.End.Column | Should -Be $columns
$sheet.ConditionalFormatting[0].Address.End.Row | should be $expectedRows $sheet.ConditionalFormatting[0].Address.End.Row | Should -Be $expectedRows
$sheet.ConditionalFormatting[0].Address.Start.Row | should be ($results.Count + 1) $sheet.ConditionalFormatting[0].Address.Start.Row | Should -Be ($results.Count + 1)
$sheet.ConditionalFormatting[0].Icon3.Type.ToString() | Should be "Num" $sheet.ConditionalFormatting[0].Icon3.Type.ToString() | Should -Be "Num"
$sheet.ConditionalFormatting[0].Icon3.Value | Should be 1 $sheet.ConditionalFormatting[0].Icon3.Value | Should -Be 1
$sheet.ConditionalFormatting[1].Priority | Should be 1 $sheet.ConditionalFormatting[1].Priority | Should -Be 1
$sheet.ConditionalFormatting[1].StopIfTrue | Should be $true $sheet.ConditionalFormatting[1].StopIfTrue | Should -Be $true
} }
It "Applied ConditionalFormatting, including Reverse " { It "Applied ConditionalFormatting, including Reverse " {
Set-ItResult -Pending -Because "Bug in EPPLus 4.5" Set-ItResult -Pending -Because "Bug in EPPLus 4.5"
$sheet.ConditionalFormatting[3].LowValue.Color.R | Should begreaterThan 180 $sheet.ConditionalFormatting[3].LowValue.Color.R | Should -BegreaterThan 180
$sheet.ConditionalFormatting[3].LowValue.Color.G | Should beLessThan 128 $sheet.ConditionalFormatting[3].LowValue.Color.G | Should -BeLessThan 128
$sheet.ConditionalFormatting[3].HighValue.Color.R | Should beLessThan 128 $sheet.ConditionalFormatting[3].HighValue.Color.R | Should -BeLessThan 128
$sheet.ConditionalFormatting[3].HighValue.Color.G | Should begreaterThan 180 $sheet.ConditionalFormatting[3].HighValue.Color.G | Should -BegreaterThan 180
} }
} }
Context "Adding a table" { Context "Adding a table" {
it "Created a table " { it "Created a table " {
$sheet.tables[0] | Should not beNullOrEmpty $sheet.tables[0] | Should -Not -BeNullOrEmpty
$sheet.tables[0].Address.Start.Column | should be 1 $sheet.tables[0].Address.Start.Column | Should -Be 1
$sheet.tables[0].Address.End.Column | should be $columns $sheet.tables[0].Address.End.Column | Should -Be $columns
$sheet.tables[0].Address.Start.row | should be ($results.Count + 1) $sheet.tables[0].Address.Start.row | Should -Be ($results.Count + 1)
$sheet.Tables[0].Address.End.Row | should be $expectedRows $sheet.Tables[0].Address.End.Row | Should -Be $expectedRows
$sheet.Tables[0].StyleName | should be "TableStyleLight4" $sheet.Tables[0].StyleName | Should -Be "TableStyleLight4"
$sheet.Tables[0].ShowColumnStripes | should be $true $sheet.Tables[0].ShowColumnStripes | Should -Be $true
$sheet.Tables[0].ShowRowStripes | should not be $true $sheet.Tables[0].ShowRowStripes | Should -Not -Be $true
} }
} }
Context "Adding Pivot tables" { Context "Adding Pivot tables" {
it "Added a worksheet with a pivot table grouped by date " { it "Added a worksheet with a pivot table grouped by date " {
$excel.Points1 | should not beNullOrEmpty $excel.Points1 | Should -Not -BeNullOrEmpty
$excel.Points1.PivotTables.Count | should be 1 $excel.Points1.PivotTables.Count | Should -Be 1
$pt = $excel.Points1.PivotTables[0] $pt = $excel.Points1.PivotTables[0]
$pt.RowFields.Count | should be 3 $pt.RowFields.Count | Should -Be 3
$pt.RowFields[0].name | should be "Driver" $pt.RowFields[0].name | Should -Be "Driver"
$pt.RowFields[0].Grouping | should benullorEmpty $pt.RowFields[0].Grouping | Should -BenullorEmpty
$pt.RowFields[1].name | should be "years" $pt.RowFields[1].name | Should -Be "years"
$pt.RowFields[1].Grouping | should not benullorEmpty $pt.RowFields[1].Grouping | Should -Not -BenullorEmpty
$pt.RowFields[2].name | should be "date" $pt.RowFields[2].name | Should -Be "date"
$pt.RowFields[2].Grouping | should not benullorEmpty $pt.RowFields[2].Grouping | Should -Not -BenullorEmpty
} }
it "Added a worksheet with a pivot table grouped by Number " { it "Added a worksheet with a pivot table grouped by Number " {
$excel.Places1 | should not beNullOrEmpty $excel.Places1 | Should -Not -BeNullOrEmpty
$excel.Places1.PivotTables.Count | should be 1 $excel.Places1.PivotTables.Count | Should -Be 1
$pt = $excel.Places1.PivotTables[0] $pt = $excel.Places1.PivotTables[0]
$pt.RowFields.Count | should be 2 $pt.RowFields.Count | Should -Be 2
$pt.RowFields[0].name | should be "Driver" $pt.RowFields[0].name | Should -Be "Driver"
$pt.RowFields[0].Grouping | should benullorEmpty $pt.RowFields[0].Grouping | Should -BenullorEmpty
$pt.RowFields[0].SubTotalFunctions.ToString() | should be "None" $pt.RowFields[0].SubTotalFunctions.ToString() | Should -Be "None"
$pt.RowFields[1].name | should be "FinishPosition" $pt.RowFields[1].name | Should -Be "FinishPosition"
$pt.RowFields[1].Grouping | should not benullorEmpty $pt.RowFields[1].Grouping | Should -Not -BenullorEmpty
$pt.RowFields[1].Grouping.Start | should be 1 $pt.RowFields[1].Grouping.Start | Should -Be 1
$pt.RowFields[1].Grouping.End | should be 25 $pt.RowFields[1].Grouping.End | Should -Be 25
$pt.RowFields[1].Grouping.Interval | should be 3 $pt.RowFields[1].Grouping.Interval | Should -Be 3
} }
} }
} }

View File

@@ -6,23 +6,23 @@ if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Describe "Check if Function aliases exist" { Describe "Check if Function aliases exist" {
It "Set-Column should exist".PadRight(90) { It "Set-Column should exist".PadRight(90) {
${Alias:Set-Column} | Should Not BeNullOrEmpty ${Alias:Set-Column} | Should -Not -BeNullOrEmpty
} }
It "Set-Row should exist".PadRight(90) { It "Set-Row should exist".PadRight(90) {
${Alias:Set-Row} | Should Not BeNullOrEmpty ${Alias:Set-Row} | Should -Not -BeNullOrEmpty
} }
It "Set-Format should exist".PadRight(90) { It "Set-Format should exist".PadRight(90) {
${Alias:Set-Format} | Should Not BeNullOrEmpty ${Alias:Set-Format} | Should -Not -BeNullOrEmpty
} }
<#It "Merge-MulipleSheets should exist" { <#It "Merge-MulipleSheets should exist" {
Get-Command Merge-MulipleSheets | Should Not Be $null Get-Command Merge-MulipleSheets | Should -Not -Be $null
} }
#> #>
It "New-ExcelChart should exist".PadRight(90) { It "New-ExcelChart should exist".PadRight(90) {
${Alias:New-ExcelChart} | Should Not BeNullOrEmpty ${Alias:New-ExcelChart} | Should -Not -BeNullOrEmpty
} }
} }

View File

@@ -17,13 +17,13 @@ $map = @{
16384 = 'XFD' 16384 = 'XFD'
} }
(Get-ExcelColumnName 26).columnName | Should be 'Z' (Get-ExcelColumnName 26).columnName | Should -Be 'Z'
(Get-ExcelColumnName 27).columnName | Should be 'AA' (Get-ExcelColumnName 27).columnName | Should -Be 'AA'
(Get-ExcelColumnName 28).columnNamee | Should be 'AB' (Get-ExcelColumnName 28).columnNamee | Should -Be 'AB'
(Get-ExcelColumnName 30).columnName | Should be 'AD' (Get-ExcelColumnName 30).columnName | Should -Be 'AD'
(Get-ExcelColumnName 48).columnName | Should be 'AV' (Get-ExcelColumnName 48).columnName | Should -Be 'AV'
1..16 | ForEach-Object { 1..16 | ForEach-Object {
$number = $_ * 1024 $number = $_ * 1024
(Get-ExcelColumnName $number).columnName | Should be $map.$number (Get-ExcelColumnName $number).columnName | Should -Be $map.$number
} }

View File

@@ -1,4 +1,5 @@
$xlfile = "TestDrive:\testImportExcel.xlsx" $xlfile = "TestDrive:\testImportExcel.xlsx"
$xlfileHeaderOnly = "TestDrive:\testImportExcelHeaderOnly.xlsx"
Describe "Import-Excel on a sheet with no headings" { Describe "Import-Excel on a sheet with no headings" {
BeforeAll { BeforeAll {
@@ -18,6 +19,15 @@ Describe "Import-Excel on a sheet with no headings" {
Set-ExcelRange -Worksheet $xl.Sheet1 -Range C3 -Value 'I' Set-ExcelRange -Worksheet $xl.Sheet1 -Range C3 -Value 'I'
Close-ExcelPackage $xl Close-ExcelPackage $xl
# crate $xlfileHeaderOnly
$xl = "" | Export-excel $xlfileHeaderOnly -PassThru
Set-ExcelRange -Worksheet $xl.Sheet1 -Range A1 -Value 'A'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range B1 -Value 'B'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range C1 -Value 'C'
Close-ExcelPackage $xl
} }
It "Import-Excel should have this shape" { It "Import-Excel should have this shape" {
@@ -25,15 +35,15 @@ Describe "Import-Excel on a sheet with no headings" {
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'A' $actualNames[0] | Should -BeExactly 'A'
$actualNames[1] | Should BeExactly 'B' $actualNames[1] | Should -BeExactly 'B'
$actualNames[2] | Should BeExactly 'C' $actualNames[2] | Should -BeExactly 'C'
$actual.Count | Should Be 2 $actual.Count | Should -Be 2
$actual[0].A | Should BeExactly 'D' $actual[0].A | Should -BeExactly 'D'
$actual[0].B | Should BeExactly 'E' $actual[0].B | Should -BeExactly 'E'
$actual[0].C | Should BeExactly 'F' $actual[0].C | Should -BeExactly 'F'
} }
It "Import-Excel -NoHeader should have this shape" { It "Import-Excel -NoHeader should have this shape" {
@@ -41,12 +51,12 @@ Describe "Import-Excel on a sheet with no headings" {
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'P1' $actualNames[0] | Should -BeExactly 'P1'
$actualNames[1] | Should BeExactly 'P2' $actualNames[1] | Should -BeExactly 'P2'
$actualNames[2] | Should BeExactly 'P3' $actualNames[2] | Should -BeExactly 'P3'
$actual.Count | Should Be 3 $actual.Count | Should -Be 3
} }
It "Import-Excel -HeaderName should have this shape" { It "Import-Excel -HeaderName should have this shape" {
@@ -54,20 +64,20 @@ Describe "Import-Excel on a sheet with no headings" {
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'Q' $actualNames[0] | Should -BeExactly 'Q'
$actualNames[1] | Should BeExactly 'R' $actualNames[1] | Should -BeExactly 'R'
$actualNames[2] | Should BeExactly 'S' $actualNames[2] | Should -BeExactly 'S'
$actual.Count | Should Be 3 $actual.Count | Should -Be 3
$actual[0].Q | Should BeExactly 'A' $actual[0].Q | Should -BeExactly 'A'
$actual[0].R | Should BeExactly 'B' $actual[0].R | Should -BeExactly 'B'
$actual[0].S | Should BeExactly 'C' $actual[0].S | Should -BeExactly 'C'
$actual[1].Q | Should BeExactly 'D' $actual[1].Q | Should -BeExactly 'D'
$actual[1].R | Should BeExactly 'E' $actual[1].R | Should -BeExactly 'E'
$actual[1].S | Should BeExactly 'F' $actual[1].S | Should -BeExactly 'F'
} }
It "Should work with StartRow" { It "Should work with StartRow" {
@@ -75,20 +85,20 @@ Describe "Import-Excel on a sheet with no headings" {
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'Q' $actualNames[0] | Should -BeExactly 'Q'
$actualNames[1] | Should BeExactly 'R' $actualNames[1] | Should -BeExactly 'R'
$actualNames[2] | Should BeExactly 'S' $actualNames[2] | Should -BeExactly 'S'
$actual.Count | Should Be 2 $actual.Count | Should -Be 2
$actual[0].Q | Should BeExactly 'D' $actual[0].Q | Should -BeExactly 'D'
$actual[0].R | Should BeExactly 'E' $actual[0].R | Should -BeExactly 'E'
$actual[0].S | Should BeExactly 'F' $actual[0].S | Should -BeExactly 'F'
$actual[1].Q | Should BeExactly 'G' $actual[1].Q | Should -BeExactly 'G'
$actual[1].R | Should BeExactly 'H' $actual[1].R | Should -BeExactly 'H'
$actual[1].S | Should BeExactly 'I' $actual[1].S | Should -BeExactly 'I'
} }
@@ -96,64 +106,64 @@ Describe "Import-Excel on a sheet with no headings" {
$actual = @(Import-Excel $xlfile -NoHeader) $actual = @(Import-Excel $xlfile -NoHeader)
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'P1' $actualNames[0] | Should -BeExactly 'P1'
$actualNames[1] | Should BeExactly 'P2' $actualNames[1] | Should -BeExactly 'P2'
$actualNames[2] | Should BeExactly 'P3' $actualNames[2] | Should -BeExactly 'P3'
$actual.Count | Should Be 3 $actual.Count | Should -Be 3
$actual[0].P1 | Should BeExactly 'A' $actual[0].P1 | Should -BeExactly 'A'
$actual[0].P2 | Should BeExactly 'B' $actual[0].P2 | Should -BeExactly 'B'
$actual[0].P3 | Should BeExactly 'C' $actual[0].P3 | Should -BeExactly 'C'
$actual[1].P1 | Should BeExactly 'D' $actual[1].P1 | Should -BeExactly 'D'
$actual[1].P2 | Should BeExactly 'E' $actual[1].P2 | Should -BeExactly 'E'
$actual[1].P3 | Should BeExactly 'F' $actual[1].P3 | Should -BeExactly 'F'
$actual[2].P1 | Should BeExactly 'G' $actual[2].P1 | Should -BeExactly 'G'
$actual[2].P2 | Should BeExactly 'H' $actual[2].P2 | Should -BeExactly 'H'
$actual[2].P3 | Should BeExactly 'I' $actual[2].P3 | Should -BeExactly 'I'
} }
It "Should work with -NoHeader -DataOnly" { It "Should work with -NoHeader -DataOnly" {
$actual = @(Import-Excel $xlfile -NoHeader -DataOnly) $actual = @(Import-Excel $xlfile -NoHeader -DataOnly)
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'P1' $actualNames[0] | Should -BeExactly 'P1'
$actualNames[1] | Should BeExactly 'P2' $actualNames[1] | Should -BeExactly 'P2'
$actualNames[2] | Should BeExactly 'P3' $actualNames[2] | Should -BeExactly 'P3'
$actual.Count | Should Be 3 $actual.Count | Should -Be 3
$actual[0].P1 | Should BeExactly 'A' $actual[0].P1 | Should -BeExactly 'A'
$actual[0].P2 | Should BeExactly 'B' $actual[0].P2 | Should -BeExactly 'B'
$actual[0].P3 | Should BeExactly 'C' $actual[0].P3 | Should -BeExactly 'C'
$actual[1].P1 | Should BeExactly 'D' $actual[1].P1 | Should -BeExactly 'D'
$actual[1].P2 | Should BeExactly 'E' $actual[1].P2 | Should -BeExactly 'E'
$actual[1].P3 | Should BeExactly 'F' $actual[1].P3 | Should -BeExactly 'F'
$actual[2].P1 | Should BeExactly 'G' $actual[2].P1 | Should -BeExactly 'G'
$actual[2].P2 | Should BeExactly 'H' $actual[2].P2 | Should -BeExactly 'H'
$actual[2].P3 | Should BeExactly 'I' $actual[2].P3 | Should -BeExactly 'I'
} }
It "Should work with -HeaderName -DataOnly -StartRow" { It "Should work with -HeaderName -DataOnly -StartRow" {
$actual = @(Import-Excel $xlfile -HeaderName 'Q', 'R', 'S' -DataOnly -StartRow 2) $actual = @(Import-Excel $xlfile -HeaderName 'Q', 'R', 'S' -DataOnly -StartRow 2)
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'Q' $actualNames[0] | Should -BeExactly 'Q'
$actualNames[1] | Should BeExactly 'R' $actualNames[1] | Should -BeExactly 'R'
$actualNames[2] | Should BeExactly 'S' $actualNames[2] | Should -BeExactly 'S'
$actual.Count | Should Be 1 $actual.Count | Should -Be 1
$actual[0].Q | Should BeExactly 'G' $actual[0].Q | Should -BeExactly 'G'
$actual[0].R | Should BeExactly 'H' $actual[0].R | Should -BeExactly 'H'
$actual[0].S | Should BeExactly 'I' $actual[0].S | Should -BeExactly 'I'
} }
It "Should" { It "Should" {
@@ -180,17 +190,38 @@ Describe "Import-Excel on a sheet with no headings" {
$actual = @(Import-Excel -Path $xlfile -DataOnly -HeaderName 'FirstName', 'SecondName', 'City' -StartRow 2) $actual = @(Import-Excel -Path $xlfile -DataOnly -HeaderName 'FirstName', 'SecondName', 'City' -StartRow 2)
$actualNames = $actual[0].psobject.properties.name $actualNames = $actual[0].psobject.properties.name
$actualNames.Count | Should Be 3 $actualNames.Count | Should -Be 3
$actualNames[0] | Should BeExactly 'FirstName' $actualNames[0] | Should -BeExactly 'FirstName'
$actualNames[1] | Should BeExactly 'SecondName' $actualNames[1] | Should -BeExactly 'SecondName'
$actualNames[2] | Should BeExactly 'City' $actualNames[2] | Should -BeExactly 'City'
$actual.Count | Should Be 1 $actual.Count | Should -Be 1
# Looks like -DataOnly does not handle empty columns # Looks like -DataOnly does not handle empty columns
# $actual[0].FirstName | Should BeExactly 'Jean-Claude' # $actual[0].FirstName | Should -BeExactly 'Jean-Claude'
# $actual[0].SecondName | Should BeExactly 'Vandamme' # $actual[0].SecondName | Should -BeExactly 'Vandamme'
# $actual[0].City | Should BeExactly 'Brussels' # $actual[0].City | Should -BeExactly 'Brussels'
} }
It "Should handle data correctly if there is only a single row" {
$actual = Import-Excel $xlfileHeaderOnly
$names = $actual.psobject.properties.Name
$names | should be $null
$actual.Count | should be 0
}
It "Should handle data correctly if there is only a single row and using -NoHeader " {
$actual = @(Import-Excel $xlfileHeaderOnly -WorksheetName Sheet1 -NoHeader)
$names = $actual[0].psobject.properties.Name
$names.count | should be 3
$names[0] | should be 'P1'
$names[1] | should be 'P2'
$names[2] | should be 'P3'
$actual.Count | should be 1
$actual[0].P1 | should be 'A'
$actual[0].P2 | should be 'B'
$actual[0].P3 | should be 'C'
}
} }

View File

@@ -12,19 +12,19 @@ Describe "Tests" {
} }
It "Should have a valid manifest".PadRight(90){ It "Should have a valid manifest".PadRight(90){
{try {Test-ModuleManifest -Path $PSScriptRoot\..\..\ImportExcel.psd1 -ErrorAction stop} {try {Test-ModuleManifest -Path $PSScriptRoot\..\..\ImportExcel.psd1 -ErrorAction stop}
catch {throw} } | should not throw catch {throw} } | Should -Not -Throw
} }
It "Should have two items in the imported simple data".PadRight(90) { It "Should have two items in the imported simple data".PadRight(90) {
$data.count | Should be 2 $data.count | Should -Be 2
} }
It "Should have items a and b in the imported simple data".PadRight(90) { It "Should have items a and b in the imported simple data".PadRight(90) {
$data[0].p1 | Should be "a" $data[0].p1 | Should -Be "a"
$data[1].p1 | Should be "b" $data[1].p1 | Should -Be "b"
} }
It "Should read the simple xlsx in < 2100 milliseconds".PadRight(90) { It "Should read the simple xlsx in < 2100 milliseconds".PadRight(90) {
$timer.TotalMilliseconds | should BeLessThan 2100 $timer.TotalMilliseconds | Should -BeLessThan 2100
} }
It "Should read larger xlsx, 4k rows 1 col < 3000 milliseconds".PadRight(90) { It "Should read larger xlsx, 4k rows 1 col < 3000 milliseconds".PadRight(90) {
@@ -32,7 +32,7 @@ Describe "Tests" {
$null = Import-Excel $PSScriptRoot\LargerFile.xlsx $null = Import-Excel $PSScriptRoot\LargerFile.xlsx
} }
$timer.TotalMilliseconds | should BeLessThan 3000 $timer.TotalMilliseconds | Should -BeLessThan 3000
} }
It "Should be able to open, read and close as seperate actions".PadRight(90) { It "Should be able to open, read and close as seperate actions".PadRight(90) {
@@ -40,30 +40,30 @@ Describe "Tests" {
$excel = Open-ExcelPackage $PSScriptRoot\Simple.xlsx $excel = Open-ExcelPackage $PSScriptRoot\Simple.xlsx
$data = Import-Excel -ExcelPackage $excel $data = Import-Excel -ExcelPackage $excel
Close-ExcelPackage -ExcelPackage $excel -NoSave} Close-ExcelPackage -ExcelPackage $excel -NoSave}
$timer.TotalMilliseconds | should BeLessThan 2100 $timer.TotalMilliseconds | Should -BeLessThan 2100
$data.count | Should be 2 $data.count | Should -Be 2
$data[0].p1 | Should be "a" $data[0].p1 | Should -Be "a"
$data[1].p1 | Should be "b" $data[1].p1 | Should -Be "b"
} }
It "Should take Paths from parameter".PadRight(90) { It "Should take Paths from parameter".PadRight(90) {
$data = Import-Excel -Path (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName $data = Import-Excel -Path (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName
$data.count | Should be 4 $data.count | Should -Be 4
$data[0].cola | Should be 1 $data[0].cola | Should -Be 1
$data[2].cola | Should be 5 $data[2].cola | Should -Be 5
} }
It "Should take Paths from pipeline".PadRight(90) { It "Should take Paths from pipeline".PadRight(90) {
$data = (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName | Import-Excel $data = (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName | Import-Excel
$data.count | Should be 4 $data.count | Should -Be 4
$data[0].cola | Should be 1 $data[0].cola | Should -Be 1
$data[2].cola | Should be 5 $data[2].cola | Should -Be 5
} }
It "Should support PipelineVariable".PadRight(90) { It "Should support PipelineVariable".PadRight(90) {
$data = Import-Excel $PSScriptRoot\Simple.xlsx -PipelineVariable 'Pv' | ForEach-Object { $Pv.p1 } $data = Import-Excel $PSScriptRoot\Simple.xlsx -PipelineVariable 'Pv' | ForEach-Object { $Pv.p1 }
$data.count | Should be 2 $data.count | Should -Be 2
$data[0] | Should be "a" $data[0] | Should -Be "a"
$data[1] | Should be "b" $data[1] | Should -Be "b"
} }
} }

View File

@@ -46,41 +46,41 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
} }
Context "Array of processes" { Context "Array of processes" {
it "Put the correct rows and columns into the sheet " { it "Put the correct rows and columns into the sheet " {
$sheet.Dimension.Rows | should be ($results.Count + 1) $sheet.Dimension.Rows | Should -Be ($results.Count + 1)
$sheet.Dimension.Columns | should be 5 $sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | should be "Name" $sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | should be "StartTime" $sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | should be $results[1].Name $sheet.cells["A3"].Value | Should -Be $results[1].Name
} }
it "Created a range for the whole sheet " { it "Created a range for the whole sheet " {
$sheet.Names[0].Name | should be "Whole" $sheet.Names[0].Name | Should -Be "Whole"
$sheet.Names[0].Start.Address | should be "A1" $sheet.Names[0].Start.Address | Should -Be "A1"
$sheet.Names[0].End.row | should be ($results.Count + 1) $sheet.Names[0].End.row | Should -Be ($results.Count + 1)
$sheet.Names[0].End.Column | should be 5 $sheet.Names[0].End.Column | Should -Be 5
} }
it "Formatted date fields with date type " { it "Formatted date fields with date type " {
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22 $sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
} }
} }
$sheet = $excel.Sheet2 $sheet = $excel.Sheet2
Context "Table of processes" { Context "Table of processes" {
it "Put the correct rows and columns into the sheet " { it "Put the correct rows and columns into the sheet " {
$sheet.Dimension.Rows | should be ($results.Count + 1) $sheet.Dimension.Rows | Should -Be ($results.Count + 1)
$sheet.Dimension.Columns | should be 5 $sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | should be "Name" $sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | should be "StartTime" $sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | should be $results[1].Name $sheet.cells["A3"].Value | Should -Be $results[1].Name
} }
it "Created named ranges for each column " { it "Created named ranges for each column " {
$sheet.Names.count | should be 5 $sheet.Names.count | Should -Be 5
$sheet.Names[0].Name | should be "Name" $sheet.Names[0].Name | Should -Be "Name"
$sheet.Names[1].Start.Address | should be "B2" $sheet.Names[1].Start.Address | Should -Be "B2"
$sheet.Names[2].End.row | should be ($results.Count + 1) $sheet.Names[2].End.row | Should -Be ($results.Count + 1)
$sheet.Names[3].End.Column | should be 4 $sheet.Names[3].End.Column | Should -Be 4
$sheet.Names[4].Start.Column | should be 5 $sheet.Names[4].Start.Column | Should -Be 5
} }
it "Formatted date fields with date type " { it "Formatted date fields with date type " {
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22 $sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
} }
} }
@@ -88,14 +88,14 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$NowPkg = Open-ExcelPackage $NowPath1 $NowPkg = Open-ExcelPackage $NowPath1
$sheet = $NowPkg.Sheet1 $sheet = $NowPkg.Sheet1
it "Formatted data as a table by default " { it "Formatted data as a table by default " {
$sheet.Tables.Count | should be 1 $sheet.Tables.Count | Should -Be 1
} }
Close-ExcelPackage -NoSave $NowPkg Close-ExcelPackage -NoSave $NowPkg
Remove-Item $NowPath1 Remove-Item $NowPath1
$NowPkg = Open-ExcelPackage $NowPath2 $NowPkg = Open-ExcelPackage $NowPath2
$sheet = $NowPkg.Sheet1 $sheet = $NowPkg.Sheet1
it "Did not data as a table when table:`$false was used " { it "Did not data as a table when table:`$false was used " {
$sheet.Tables.Count | should be 0 $sheet.Tables.Count | Should -Be 0
} }
Close-ExcelPackage -NoSave $NowPkg Close-ExcelPackage -NoSave $NowPkg
Remove-Item $NowPath2 Remove-Item $NowPath2
@@ -103,37 +103,37 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$sheet = $excel.Sheet3 $sheet = $excel.Sheet3
Context "Table of processes via Send-SQLDataToExcel" { Context "Table of processes via Send-SQLDataToExcel" {
it "Put the correct data rows and columns into the sheet " { it "Put the correct data rows and columns into the sheet " {
$sheet.Dimension.Rows | should be ($results.Count + 1) $sheet.Dimension.Rows | Should -Be ($results.Count + 1)
$sheet.Dimension.Columns | should be 5 $sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | should be "Name" $sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | should be "StartTime" $sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | should be $results[1].Name $sheet.cells["A3"].Value | Should -Be $results[1].Name
} }
it "Created a table " { it "Created a table " {
$sheet.Tables.count | should be 1 $sheet.Tables.count | Should -Be 1
$sheet.Tables[0].Columns[4].name | should be "StartTime" $sheet.Tables[0].Columns[4].name | Should -Be "StartTime"
} }
it "Formatted date fields with date type " { it "Formatted date fields with date type " {
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22 $sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
} }
it "Handled two data tables with the same name " { it "Handled two data tables with the same name " {
$sheet.Tables[0].Name | should be "Data_" $sheet.Tables[0].Name | Should -Be "Data_"
$wvThree[0] | should match "is not unique" $wvThree[0] | Should -Match "is not unique"
} }
} }
$Sheet = $excel.Sheet4 $Sheet = $excel.Sheet4
Context "Zero-row Data Table sent with Send-SQLDataToExcel -Force" { Context "Zero-row Data Table sent with Send-SQLDataToExcel -Force" {
it "Raised a warning and put the correct data headers into the sheet " { it "Raised a warning and put the correct data headers into the sheet " {
$sheet.Dimension.Rows | should be 1 $sheet.Dimension.Rows | Should -Be 1
$sheet.Dimension.Columns | should be 5 $sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | should be "Name" $sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | should be "StartTime" $sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | should beNullOrEmpty $sheet.cells["A3"].Value | Should -BeNullOrEmpty
$wvone[0] | should match "Zero" $wvone[0] | Should -Match "Zero"
} }
it "Applied table formatting " { it "Applied table formatting " {
$sheet.Tables.Count | should be 1 $sheet.Tables.Count | Should -Be 1
$sheet.Tables[0].Name | should be "Data" $sheet.Tables[0].Name | Should -Be "Data"
} }
@@ -141,8 +141,8 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$Sheet = $excel.Sheet5 $Sheet = $excel.Sheet5
Context "Zero-column Data Table handled by Send-SQLDataToExcel -Force" { Context "Zero-column Data Table handled by Send-SQLDataToExcel -Force" {
it "Created a blank Sheet and raised a warning " { it "Created a blank Sheet and raised a warning " {
$sheet.Dimension | should beNullOrEmpty $sheet.Dimension | Should -BeNullOrEmpty
$wvTwo | should not beNullOrEmpty $wvTwo | Should -Not -BeNullOrEmpty
} }
} }
@@ -150,32 +150,32 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$excel = Open-ExcelPackage $path2 $excel = Open-ExcelPackage $path2
Context "Send-SQLDataToExcel -append works correctly" { Context "Send-SQLDataToExcel -append works correctly" {
it "Works without table settings " { it "Works without table settings " {
$excel.sheet1.Dimension.Address | should be "A1:E21" $excel.sheet1.Dimension.Address | Should -Be "A1:E21"
$excel.sheet1.cells[1,1].value | should be "Name" $excel.sheet1.cells[1,1].value | Should -Be "Name"
$excel.sheet1.cells[12,1].value | should be $excel.sheet1.cells[2,1].value $excel.sheet1.cells[12,1].value | Should -Be $excel.sheet1.cells[2,1].value
$excel.sheet1.Tables.count | should be 0 $excel.sheet1.Tables.count | Should -Be 0
} }
it "Extends an existing table when appending " { it "Extends an existing table when appending " {
$excel.sheet2.Dimension.Address | should be "A1:E21" $excel.sheet2.Dimension.Address | Should -Be "A1:E21"
$excel.sheet2.cells[1,2].value | should be "CPU" $excel.sheet2.cells[1,2].value | Should -Be "CPU"
$excel.sheet2.cells[13,2].value | should be $excel.sheet2.cells[3,2].value $excel.sheet2.cells[13,2].value | Should -Be $excel.sheet2.cells[3,2].value
$excel.sheet2.Tables.count | should be 1 $excel.sheet2.Tables.count | Should -Be 1
$excel.sheet2.Tables[0].name | should be "FirstLot" $excel.sheet2.Tables[0].name | Should -Be "FirstLot"
$excel.sheet2.Tables[0].StyleName | should be "TableStyleLight7" $excel.sheet2.Tables[0].StyleName | Should -Be "TableStyleLight7"
} }
it "Creates a new table by name when appending " { it "Creates a new table by name when appending " {
$excel.sheet3.cells[1,3].value | should be "PM" $excel.sheet3.cells[1,3].value | Should -Be "PM"
$excel.sheet3.cells[14,3].value | should be $excel.sheet3.cells[4,3].value $excel.sheet3.cells[14,3].value | Should -Be $excel.sheet3.cells[4,3].value
$excel.sheet3.Tables.count | should be 1 $excel.sheet3.Tables.count | Should -Be 1
$excel.sheet3.Tables[0].name | should be "SecondLot" $excel.sheet3.Tables[0].name | Should -Be "SecondLot"
$excel.sheet3.Tables[0].StyleName | should be "TableStyleMedium6" $excel.sheet3.Tables[0].StyleName | Should -Be "TableStyleMedium6"
} }
it "Creates a new table by style when appending " { it "Creates a new table by style when appending " {
$excel.sheet4.cells[1,4].value | should be "Handles" $excel.sheet4.cells[1,4].value | Should -Be "Handles"
$excel.sheet4.cells[15,4].value | should be $excel.sheet4.cells[5,4].value $excel.sheet4.cells[15,4].value | Should -Be $excel.sheet4.cells[5,4].value
$excel.sheet4.Tables.count | should be 1 $excel.sheet4.Tables.count | Should -Be 1
$excel.sheet4.Tables[0].name | should be "Table1" $excel.sheet4.Tables[0].name | Should -Be "Table1"
$excel.sheet4.Tables[0].StyleName | should be "TableStyleDark5" $excel.sheet4.Tables[0].StyleName | Should -Be "TableStyleDark5"
} }
} }
@@ -183,9 +183,9 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
Context "Import As Text returns text values" { Context "Import As Text returns text values" {
$x = Import-excel $path -WorksheetName sheet3 -AsText StartTime,hand* | Select-Object -last 1 $x = Import-excel $path -WorksheetName sheet3 -AsText StartTime,hand* | Select-Object -last 1
it "Had fields of type string, not date or int, where specified as ASText " { it "Had fields of type string, not date or int, where specified as ASText " {
$x.Handles.GetType().Name | should be "String" $x.Handles.GetType().Name | Should -Be "String"
$x.StartTime.GetType().Name | should be "String" $x.StartTime.GetType().Name | Should -Be "String"
$x.CPU.GetType().Name | should not be "String" $x.CPU.GetType().Name | Should -Not -Be "String"
} }
} }

View File

@@ -44,52 +44,52 @@ Describe "Join Worksheet part 1" {
} }
Context "Export-Excel setting spreadsheet visibility" { Context "Export-Excel setting spreadsheet visibility" {
it "Hid the worksheets " { it "Hid the worksheets " {
$excel.Workbook.Worksheets["Oxford"].Hidden | Should be 'Hidden' $excel.Workbook.Worksheets["Oxford"].Hidden | Should -Be 'Hidden'
$excel.Workbook.Worksheets["Banbury"].Hidden | Should be 'Hidden' $excel.Workbook.Worksheets["Banbury"].Hidden | Should -Be 'Hidden'
$excel.Workbook.Worksheets["Abingdon"].Hidden | Should be 'Hidden' $excel.Workbook.Worksheets["Abingdon"].Hidden | Should -Be 'Hidden'
} }
it "Un-hid two of the worksheets " { it "Un-hid two of the worksheets " {
$excel.Workbook.Worksheets["Total"].Hidden | Should be 'Visible' $excel.Workbook.Worksheets["Total"].Hidden | Should -Be 'Visible'
$excel.Workbook.Worksheets["SummaryPivot"].Hidden | Should be 'Visible' $excel.Workbook.Worksheets["SummaryPivot"].Hidden | Should -Be 'Visible'
} }
it "Activated the correct worksheet " { it "Activated the correct worksheet " {
Set-ItResult -Pending -Because "Bug in EPPLus 4.5" Set-ItResult -Pending -Because "Bug in EPPLus 4.5"
$excel.Workbook.worksheets["SummaryPivot"].View.TabSelected | Should be $true $excel.Workbook.worksheets["SummaryPivot"].View.TabSelected | Should -Be $true
$excel.Workbook.worksheets["Total"].View.TabSelected | Should be $false $excel.Workbook.worksheets["Total"].View.TabSelected | Should -Be $false
} }
} }
Context "Merging 3 blocks" { Context "Merging 3 blocks" {
it "Created sheet of the right size with a title and a table " { it "Created sheet of the right size with a title and a table " {
$ws.Dimension.Address | Should be "A1:F16" $ws.Dimension.Address | Should -Be "A1:F16"
$ws.Tables[0].Address.Address | Should be "A2:F16" $ws.Tables[0].Address.Address | Should -Be "A2:F16"
$ws.Cells["A1"].Value | Should be "Store Sales Summary" $ws.Cells["A1"].Value | Should -Be "Store Sales Summary"
$ws.Cells["A1"].Style.Font.Size | Should be 14 $ws.Cells["A1"].Style.Font.Size | Should -Be 14
$ws.Cells["A1"].Style.Font.Bold | Should be $True $ws.Cells["A1"].Style.Font.Bold | Should -Be $True
$ws.Cells["A1"].Style.Fill.BackgroundColor.Rgb | Should be "FFF0F8FF" $ws.Cells["A1"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFF0F8FF"
$ws.Cells["A1"].Style.Fill.PatternType.ToString() | Should be "Solid" $ws.Cells["A1"].Style.Fill.PatternType.ToString() | Should -Be "Solid"
$ws.Tables[0].StyleName | Should be "TableStyleLight1" $ws.Tables[0].StyleName | Should -Be "TableStyleLight1"
$ws.Cells["A2:F2"].Style.Font.Bold | Should be $True $ws.Cells["A2:F2"].Style.Font.Bold | Should -Be $True
} }
it "Added a from column with the right heading " { it "Added a from column with the right heading " {
$ws.Cells["F2" ].Value | Should be "Store" $ws.Cells["F2" ].Value | Should -Be "Store"
$ws.Cells["F3" ].Value | Should be "Oxford" $ws.Cells["F3" ].Value | Should -Be "Oxford"
$ws.Cells["F8" ].Value | Should be "Abingdon" $ws.Cells["F8" ].Value | Should -Be "Abingdon"
$ws.Cells["F13"].Value | Should be "Banbury" $ws.Cells["F13"].Value | Should -Be "Banbury"
} }
it "Filled in the data " { it "Filled in the data " {
$ws.Cells["C3" ].Value | Should be $data1[0].quantity $ws.Cells["C3" ].Value | Should -Be $data1[0].quantity
$ws.Cells["C8" ].Value | Should be $data2[0].quantity $ws.Cells["C8" ].Value | Should -Be $data2[0].quantity
$ws.Cells["C13"].Value | Should be $data3[0].quantity $ws.Cells["C13"].Value | Should -Be $data3[0].quantity
} }
it "Created the pivot table " { it "Created the pivot table " {
$pt | Should not beNullOrEmpty $pt | Should -Not -BeNullOrEmpty
$pt.StyleName | Should be "PivotStyleMedium9" $pt.StyleName | Should -Be "PivotStyleMedium9"
$pt.RowFields[0].Name | Should be "Store" $pt.RowFields[0].Name | Should -Be "Store"
$pt.ColumnFields[0].name | Should be "Product" $pt.ColumnFields[0].name | Should -Be "Product"
$pt.DataFields[0].name | Should be "Sum of Total" $pt.DataFields[0].name | Should -Be "Sum of Total"
$pc.ChartType | Should be "ColumnStacked" $pc.ChartType | Should -Be "ColumnStacked"
$pc.Title.text | Should be "Sales Breakdown" $pc.Title.text | Should -Be "Sales Breakdown"
} }
} }
} }
@@ -109,22 +109,22 @@ Describe "Join Worksheet part 2" {
$ws = $excel.Workbook.Worksheets["Summary"] $ws = $excel.Workbook.Worksheets["Summary"]
Context "Bringing 3 Unlinked blocks onto one page" { Context "Bringing 3 Unlinked blocks onto one page" {
it "Hid the source worksheets " { it "Hid the source worksheets " {
$excel.Workbook.Worksheets[1].Hidden.tostring() | Should be "Hidden" $excel.Workbook.Worksheets[1].Hidden.tostring() | Should -Be "Hidden"
$excel.Workbook.Worksheets[2].Hidden.tostring() | Should be "Hidden" $excel.Workbook.Worksheets[2].Hidden.tostring() | Should -Be "Hidden"
} }
it "Created the Summary sheet with title, and block labels, and copied the correct data " { it "Created the Summary sheet with title, and block labels, and copied the correct data " {
$ws.Cells["A1"].Value | Should be "Summary" $ws.Cells["A1"].Value | Should -Be "Summary"
$ws.Cells["A2"].Value | Should be $excel.Workbook.Worksheets[1].name $ws.Cells["A2"].Value | Should -Be $excel.Workbook.Worksheets[1].name
$ws.Cells["A3"].Value | Should be $excel.Workbook.Worksheets[1].Cells["A1"].value $ws.Cells["A3"].Value | Should -Be $excel.Workbook.Worksheets[1].Cells["A1"].value
$ws.Cells["A4"].Value | Should be $excel.Workbook.Worksheets[1].Cells["A2"].value $ws.Cells["A4"].Value | Should -Be $excel.Workbook.Worksheets[1].Cells["A2"].value
$ws.Cells["B4"].Value | Should be $excel.Workbook.Worksheets[1].Cells["B2"].value $ws.Cells["B4"].Value | Should -Be $excel.Workbook.Worksheets[1].Cells["B2"].value
$nextRow = $excel.Workbook.Worksheets[1].Dimension.Rows + 3 $nextRow = $excel.Workbook.Worksheets[1].Dimension.Rows + 3
$ws.Cells["A$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].name $ws.Cells["A$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].name
$nextRow ++ $nextRow ++
$ws.Cells["A$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].Cells["A1"].value $ws.Cells["A$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].Cells["A1"].value
$nextRow ++ $nextRow ++
$ws.Cells["A$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].Cells["A2"].value $ws.Cells["A$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].Cells["A2"].value
$ws.Cells["B$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].Cells["B2"].value $ws.Cells["B$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].Cells["B2"].value
} }
} }
} }

View File

@@ -15,17 +15,17 @@ Describe "Password Support" {
Get-Service | Select-Object -First 10 | Export-excel -password $password -Path $Path -DisplayPropertySet Get-Service | Select-Object -First 10 | Export-excel -password $password -Path $Path -DisplayPropertySet
} }
it "Threw an error when the password was omitted " { it "Threw an error when the password was omitted " {
{Open-ExcelPackage -Path $path } | should throw {Open-ExcelPackage -Path $path } | Should -Throw
} }
it "Was able to append when the password was included " { it "Was able to append when the password was included " {
{Get-Service | Select-Object -First 10 | {Get-Service | Select-Object -First 10 |
Export-excel -password $password -Path $Path -Append } | should not throw Export-excel -password $password -Path $Path -Append } | Should -Not -Throw
} }
it "Kept the password on the file when it was saved " { it "Kept the password on the file when it was saved " {
{Import-Excel $Path } | should throw {Import-Excel $Path } | Should -Throw
} }
it "Could read the file when the password was included " { it "Could read the file when the password was included " {
(Import-excel $path -Password $password).count | should be 20 (Import-excel $path -Password $password).count | Should -Be 20
} }
} }
} }

View File

@@ -10,29 +10,29 @@
It "Should read local file".PadRight(90) { It "Should read local file".PadRight(90) {
$actual = Import-Excel -Path ".\$($script:xlfileName)" $actual = Import-Excel -Path ".\$($script:xlfileName)"
$actual | Should Not Be $null $actual | Should -Not -Be $null
$actual.Count | Should Be 1 $actual.Count | Should -Be 1
} }
It "Should read with pwd".PadRight(90){ It "Should read with pwd".PadRight(90){
$actual = Import-Excel -Path (Join-Path $PWD "$($script:xlfileName)") $actual = Import-Excel -Path (Join-Path $PWD "$($script:xlfileName)")
$actual | Should Not Be $null $actual | Should -Not -Be $null
} }
It "Should read with just a file name and resolve to cwd".PadRight(90){ It "Should read with just a file name and resolve to cwd".PadRight(90){
$actual = Import-Excel -Path "$($script:xlfileName)" $actual = Import-Excel -Path "$($script:xlfileName)"
$actual | Should Not Be $null $actual | Should -Not -Be $null
} }
It "Should fail for not found".PadRight(90){ It "Should fail for not found".PadRight(90){
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsx" } | Should Throw "'ExcelFileDoesNotExist.xlsx' file not found" { Import-Excel -Path "ExcelFileDoesNotExist.xlsx" } | Should -Throw "'ExcelFileDoesNotExist.xlsx' file not found"
} }
It "Should fail for xls extension".PadRight(90){ It "Should fail for xls extension".PadRight(90){
{ Import-Excel -Path "ExcelFileDoesNotExist.xls" } | Should Throw "Import-Excel does not support reading this extension type .xls" { Import-Excel -Path "ExcelFileDoesNotExist.xls" } | Should -Throw "Import-Excel does not support reading this extension type .xls"
} }
It "Should fail for xlsxs extension".PadRight(90){ It "Should fail for xlsxs extension".PadRight(90){
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsxs" } | Should Throw "Import-Excel does not support reading this extension type .xlsxs" { Import-Excel -Path "ExcelFileDoesNotExist.xlsxs" } | Should -Throw "Import-Excel does not support reading this extension type .xlsxs"
} }
} }

View File

@@ -22,15 +22,15 @@ Apple, New York, 1200,700
$ws = $ws = $excel.sheet1 $ws = $ws = $excel.sheet1
} }
it "Turned on protection for the sheet " { it "Turned on protection for the sheet " {
$ws.Protection.IsProtected | should be $true $ws.Protection.IsProtected | Should -Be $true
} }
it "Set sheet-wide protection options " { it "Set sheet-wide protection options " {
$ws.Protection.AllowEditObject | should be $false $ws.Protection.AllowEditObject | Should -Be $false
$ws.Protection.AllowFormatRows | should be $true $ws.Protection.AllowFormatRows | Should -Be $true
$ws.cells["a2"].Style.Locked | should be $true $ws.cells["a2"].Style.Locked | Should -Be $true
} }
it "Unprotected some cells " { it "Unprotected some cells " {
$ws.cells["a1"].Style.Locked | should be $false $ws.cells["a1"].Style.Locked | Should -Be $false
} }
} }

View File

@@ -6,36 +6,36 @@ describe "Consistent passing of ranges." {
Remove-Item -path $path -ErrorAction SilentlyContinue Remove-Item -path $path -ErrorAction SilentlyContinue
$excel = Get-Service | Export-Excel -Path $path -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -AutoNameRange -Title "Services on $Env:COMPUTERNAME" $excel = Get-Service | Export-Excel -Path $path -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -AutoNameRange -Title "Services on $Env:COMPUTERNAME"
it "accepts named ranges, cells['name'], worksheet + Name, worksheet + column " { it "accepts named ranges, cells['name'], worksheet + Name, worksheet + column " {
{Add-ConditionalFormatting $excel.Services.Names["Status"] -StrikeThru -RuleType ContainsText -ConditionValue "Stopped" } | Should not throw {Add-ConditionalFormatting $excel.Services.Names["Status"] -StrikeThru -RuleType ContainsText -ConditionValue "Stopped" } | Should -Not -Throw
$excel.Services.ConditionalFormatting.Count | Should be 1 $excel.Services.ConditionalFormatting.Count | Should -Be 1
{Add-ConditionalFormatting $excel.Services.Cells["Name"] -Italic -RuleType ContainsText -ConditionValue "SVC" } | Should not throw {Add-ConditionalFormatting $excel.Services.Cells["Name"] -Italic -RuleType ContainsText -ConditionValue "SVC" } | Should -Not -Throw
$excel.Services.ConditionalFormatting.Count | Should be 2 $excel.Services.ConditionalFormatting.Count | Should -Be 2
$warnvar = $null $warnvar = $null
Add-ConditionalFormatting $excel.Services.Column(3) ` Add-ConditionalFormatting $excel.Services.Column(3) `
-underline -RuleType ContainsText -ConditionValue "Windows" -WarningVariable warnvar -WarningAction SilentlyContinue -underline -RuleType ContainsText -ConditionValue "Windows" -WarningVariable warnvar -WarningAction SilentlyContinue
$warnvar | should not beNullOrEmpty $warnvar | Should -Not -BeNullOrEmpty
$excel.Services.ConditionalFormatting.Count | Should be 2 $excel.Services.ConditionalFormatting.Count | Should -Be 2
$warnvar = $null $warnvar = $null
Add-ConditionalFormatting $excel.Services.Column(3) -Worksheet $excel.Services` Add-ConditionalFormatting $excel.Services.Column(3) -Worksheet $excel.Services`
-underline -RuleType ContainsText -ConditionValue "Windows" -WarningVariable warnvar -WarningAction SilentlyContinue -underline -RuleType ContainsText -ConditionValue "Windows" -WarningVariable warnvar -WarningAction SilentlyContinue
$warnvar | should beNullOrEmpty $warnvar | Should -BeNullOrEmpty
$excel.Services.ConditionalFormatting.Count | Should be 3 $excel.Services.ConditionalFormatting.Count | Should -Be 3
{Add-ConditionalFormatting "Status" -Worksheet $excel.Services ` {Add-ConditionalFormatting "Status" -Worksheet $excel.Services `
-ForeGroundColor ([System.Drawing.Color]::Green) -RuleType ContainsText -ConditionValue "Running"} | Should not throw -ForeGroundColor ([System.Drawing.Color]::Green) -RuleType ContainsText -ConditionValue "Running"} | Should -Not -Throw
$excel.Services.ConditionalFormatting.Count | Should be 4 $excel.Services.ConditionalFormatting.Count | Should -Be 4
} }
Close-ExcelPackage -NoSave $excel Close-ExcelPackage -NoSave $excel
$excel = Get-Service | Export-Excel -Path $path -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -TableName servicetable -Title "Services on $Env:COMPUTERNAME" $excel = Get-Service | Export-Excel -Path $path -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -TableName servicetable -Title "Services on $Env:COMPUTERNAME"
it "accepts table, table.Address and worksheet + 'C:C' " { it "accepts table, table.Address and worksheet + 'C:C' " {
{Add-ConditionalFormatting $excel.Services.Tables[0] ` {Add-ConditionalFormatting $excel.Services.Tables[0] `
-Italic -RuleType ContainsText -ConditionValue "Svc" } | Should not throw -Italic -RuleType ContainsText -ConditionValue "Svc" } | Should -Not -Throw
$excel.Services.ConditionalFormatting.Count | Should be 1 $excel.Services.ConditionalFormatting.Count | Should -Be 1
{Add-ConditionalFormatting $excel.Services.Tables["ServiceTable"].Address ` {Add-ConditionalFormatting $excel.Services.Tables["ServiceTable"].Address `
-Bold -RuleType ContainsText -ConditionValue "windows" } | Should not throw -Bold -RuleType ContainsText -ConditionValue "windows" } | Should -Not -Throw
$excel.Services.ConditionalFormatting.Count | Should be 2 $excel.Services.ConditionalFormatting.Count | Should -Be 2
{Add-ConditionalFormatting -Worksheet $excel.Services -Address "a:a" ` {Add-ConditionalFormatting -Worksheet $excel.Services -Address "a:a" `
-RuleType ContainsText -ConditionValue "stopped" -ForeGroundColor ([System.Drawing.Color]::Red) } | Should not throw -RuleType ContainsText -ConditionValue "stopped" -ForeGroundColor ([System.Drawing.Color]::Red) } | Should -Not -Throw
$excel.Services.ConditionalFormatting.Count | Should be 3 $excel.Services.ConditionalFormatting.Count | Should -Be 3
} }
Close-ExcelPackage -NoSave $excel Close-ExcelPackage -NoSave $excel
} }
@@ -43,29 +43,29 @@ describe "Consistent passing of ranges." {
Context "Formating (Set-ExcelRange or its alias Set-Format) " { Context "Formating (Set-ExcelRange or its alias Set-Format) " {
it "accepts Named Range, cells['Name'], cells['A1:Z9'], row, Worksheet + 'A1:Z9'" { it "accepts Named Range, cells['Name'], cells['A1:Z9'], row, Worksheet + 'A1:Z9'" {
$excel = Get-Service | Export-Excel -Path test2.xlsx -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -RangeName servicerange -Title "Services on $Env:COMPUTERNAME" $excel = Get-Service | Export-Excel -Path test2.xlsx -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -RangeName servicerange -Title "Services on $Env:COMPUTERNAME"
{Set-format $excel.Services.Names["serviceRange"] -Bold } | Should Not Throw {Set-format $excel.Services.Names["serviceRange"] -Bold } | Should -Not -Throw
$excel.Services.cells["B2"].Style.Font.Bold | Should be $true $excel.Services.cells["B2"].Style.Font.Bold | Should -Be $true
{Set-ExcelRange -Range $excel.Services.Cells["serviceRange"] -italic:$true } | Should not throw {Set-ExcelRange -Range $excel.Services.Cells["serviceRange"] -italic:$true } | Should -Not -Throw
$excel.Services.cells["C3"].Style.Font.Italic | Should be $true $excel.Services.cells["C3"].Style.Font.Italic | Should -Be $true
{Set-format $excel.Services.Row(4) -underline -Bold:$false } | Should not throw {Set-format $excel.Services.Row(4) -underline -Bold:$false } | Should -Not -Throw
$excel.Services.cells["A4"].Style.Font.UnderLine | Should be $true $excel.Services.cells["A4"].Style.Font.UnderLine | Should -Be $true
$excel.Services.cells["A4"].Style.Font.Bold | Should not be $true $excel.Services.cells["A4"].Style.Font.Bold | Should -Not -Be $true
{Set-ExcelRange $excel.Services.Cells["A3:B3"] -StrikeThru } | Should not throw {Set-ExcelRange $excel.Services.Cells["A3:B3"] -StrikeThru } | Should -Not -Throw
$excel.Services.cells["B3"].Style.Font.Strike | Should be $true $excel.Services.cells["B3"].Style.Font.Strike | Should -Be $true
{Set-ExcelRange -Worksheet $excel.Services -Range "A5:B6" -FontSize 8 } | Should not throw {Set-ExcelRange -Worksheet $excel.Services -Range "A5:B6" -FontSize 8 } | Should -Not -Throw
$excel.Services.cells["A5"].Style.Font.Size | Should be 8 $excel.Services.cells["A5"].Style.Font.Size | Should -Be 8
} }
Close-ExcelPackage -NoSave $excel Close-ExcelPackage -NoSave $excel
it "Accepts Table, Table.Address , worksheet + Name, Column," { it "Accepts Table, Table.Address , worksheet + Name, Column," {
$excel = Get-Service | Export-Excel -Path test2.xlsx -WorksheetName Services -PassThru -AutoNameRange -AutoSize -DisplayPropertySet -TableName servicetable -Title "Services on $Env:COMPUTERNAME" $excel = Get-Service | Export-Excel -Path test2.xlsx -WorksheetName Services -PassThru -AutoNameRange -AutoSize -DisplayPropertySet -TableName servicetable -Title "Services on $Env:COMPUTERNAME"
{Set-ExcelRange $excel.Services.Tables[0] -Italic } | Should not throw {Set-ExcelRange $excel.Services.Tables[0] -Italic } | Should -Not -Throw
$excel.Services.cells["C3"].Style.Font.Italic | Should be $true $excel.Services.cells["C3"].Style.Font.Italic | Should -Be $true
{Set-format $excel.Services.Tables["ServiceTable"].Address -Underline } | Should not throw {Set-format $excel.Services.Tables["ServiceTable"].Address -Underline } | Should -Not -Throw
$excel.Services.cells["C3"].Style.Font.UnderLine | Should be $true $excel.Services.cells["C3"].Style.Font.UnderLine | Should -Be $true
{Set-ExcelRange -Worksheet $excel.Services -Range "Name" -Bold } | Should not throw {Set-ExcelRange -Worksheet $excel.Services -Range "Name" -Bold } | Should -Not -Throw
$excel.Services.cells["B4"].Style.Font.Bold | Should be $true $excel.Services.cells["B4"].Style.Font.Bold | Should -Be $true
{$excel.Services.Column(3) | Set-ExcelRange -FontColor ([System.Drawing.Color]::Red) } | Should not throw {$excel.Services.Column(3) | Set-ExcelRange -FontColor ([System.Drawing.Color]::Red) } | Should -Not -Throw
$excel.Services.cells["C4"].Style.Font.Color.Rgb | Should be "FFFF0000" $excel.Services.cells["C4"].Style.Font.Color.Rgb | Should -Be "FFFF0000"
} }
Close-ExcelPackage -NoSave $excel Close-ExcelPackage -NoSave $excel
} }
@@ -77,24 +77,24 @@ describe "Consistent passing of ranges." {
$end = $ws.Dimension.End.Address $end = $ws.Dimension.End.Address
#can get a named ranged by name or index - starting at zero #can get a named ranged by name or index - starting at zero
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt0 -SourceRange $ws.Names[0]` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt0 -SourceRange $ws.Names[0]`
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt0"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt0"] | Should -Not -BeNullOrEmpty
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt1 -SourceRange $ws.Names["servicerange"]` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt1 -SourceRange $ws.Names["servicerange"]`
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt1"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt1"] | Should -Not -BeNullOrEmpty
#Can specify the range for a pivot as NamedRange or Table or TableAddress or Worksheet + "A1:Z10" or worksheet + RangeName, or worksheet.cells["A1:Z10"] or worksheet.cells["RangeName"] #Can specify the range for a pivot as NamedRange or Table or TableAddress or Worksheet + "A1:Z10" or worksheet + RangeName, or worksheet.cells["A1:Z10"] or worksheet.cells["RangeName"]
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt2 -SourceRange "servicerange" -SourceWorkSheet $ws ` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt2 -SourceRange "servicerange" -SourceWorkSheet $ws `
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt2"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt2"] | Should -Not -BeNullOrEmpty
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt3 -SourceRange $ws.cells["servicerange"]` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt3 -SourceRange $ws.cells["servicerange"]`
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt3"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt3"] | Should -Not -BeNullOrEmpty
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt4 -SourceRange $ws.cells["A2:$end"]` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt4 -SourceRange $ws.cells["A2:$end"]`
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt4"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt4"] | Should -Not -BeNullOrEmpty
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt5 -SourceRange "A2:$end" -SourceWorkSheet $ws ` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt5 -SourceRange "A2:$end" -SourceWorkSheet $ws `
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt5"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt5"] | Should -Not -BeNullOrEmpty
Close-ExcelPackage -NoSave $excel Close-ExcelPackage -NoSave $excel
} }
it "Accepts Table, Table.Addres " { it "Accepts Table, Table.Addres " {
@@ -102,11 +102,11 @@ describe "Consistent passing of ranges." {
$ws = $excel.Workbook.Worksheets["Services"] #can get a worksheet by name or index - starting at 1 $ws = $excel.Workbook.Worksheets["Services"] #can get a worksheet by name or index - starting at 1
#Can get a table by name or -stating at zero. Can specify the range for a pivot as or Table or TableAddress #Can get a table by name or -stating at zero. Can specify the range for a pivot as or Table or TableAddress
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt1 -SourceRange $ws.tables["servicetable"]` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt1 -SourceRange $ws.tables["servicetable"]`
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt1"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt1"] | Should -Not -BeNullOrEmpty
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt2 -SourceRange $ws.tables[0].Address ` {Add-PivotTable -ExcelPackage $excel -PivotTableName pt2 -SourceRange $ws.tables[0].Address `
-PivotRows Status -PivotData Name } | Should not throw -PivotRows Status -PivotData Name } | Should -Not -Throw
$excel.Workbook.Worksheets["pt2"] | Should not beNullOrEmpty $excel.Workbook.Worksheets["pt2"] | Should -Not -BeNullOrEmpty
Close-ExcelPackage -NoSave $excel Close-ExcelPackage -NoSave $excel
} }

View File

@@ -29,7 +29,7 @@ John,20
} }
it "Should throw about the Path".PadRight(87) { it "Should throw about the Path".PadRight(87) {
{Remove-Worksheet} | Should throw 'Remove-Worksheet requires the and Excel file' {Remove-Worksheet} | Should -Throw 'Remove-Worksheet requires the and Excel file'
} }
it "Should delete Target2".PadRight(87) { it "Should delete Target2".PadRight(87) {
@@ -37,10 +37,10 @@ John,20
$actual = Get-ExcelSheetInfo -Path $xlFile1 $actual = Get-ExcelSheetInfo -Path $xlFile1
$actual.Count | Should Be 3 $actual.Count | Should -Be 3
$actual[0].Name | Should Be "Target1" $actual[0].Name | Should -Be "Target1"
$actual[1].Name | Should Be "Target3" $actual[1].Name | Should -Be "Target3"
$actual[2].Name | Should Be "Sheet1" $actual[2].Name | Should -Be "Sheet1"
} }
it "Should delete Sheet1".PadRight(87) { it "Should delete Sheet1".PadRight(87) {
@@ -48,10 +48,10 @@ John,20
$actual = Get-ExcelSheetInfo -Path $xlFile1 $actual = Get-ExcelSheetInfo -Path $xlFile1
$actual.Count | Should Be 3 $actual.Count | Should -Be 3
$actual[0].Name | Should Be "Target1" $actual[0].Name | Should -Be "Target1"
$actual[1].Name | Should Be "Target2" $actual[1].Name | Should -Be "Target2"
$actual[2].Name | Should Be "Target3" $actual[2].Name | Should -Be "Target3"
} }
it "Should delete multiple sheets".PadRight(87) { it "Should delete multiple sheets".PadRight(87) {
@@ -59,9 +59,9 @@ John,20
$actual = Get-ExcelSheetInfo -Path $xlFile1 $actual = Get-ExcelSheetInfo -Path $xlFile1
$actual.Count | Should Be 2 $actual.Count | Should -Be 2
$actual[0].Name | Should Be "Target2" $actual[0].Name | Should -Be "Target2"
$actual[1].Name | Should Be "Target3" $actual[1].Name | Should -Be "Target3"
} }
it "Should delete sheet from multiple workbooks".PadRight(87) { it "Should delete sheet from multiple workbooks".PadRight(87) {
@@ -70,10 +70,10 @@ John,20
$actual = Get-ExcelSheetInfo -Path $xlFile1 $actual = Get-ExcelSheetInfo -Path $xlFile1
$actual.Count | Should Be 3 $actual.Count | Should -Be 3
$actual[0].Name | Should Be "Target1" $actual[0].Name | Should -Be "Target1"
$actual[1].Name | Should Be "Target2" $actual[1].Name | Should -Be "Target2"
$actual[2].Name | Should Be "Target3" $actual[2].Name | Should -Be "Target3"
} }
} }
} }

View File

@@ -29,16 +29,16 @@ Describe "Number format expansion and setting" {
Context "Expand-NumberFormat function" { Context "Expand-NumberFormat function" {
It "Expanded named number formats as expected " { It "Expanded named number formats as expected " {
$r = [regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol) $r = [regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol)
Expand-NumberFormat 'Currency' | Should match "^[$r\(\)\[\] RED0#\?\-;,.]+$" Expand-NumberFormat 'Currency' | Should -Match "^[$r\(\)\[\] RED0#\?\-;,.]+$"
Expand-NumberFormat 'Number' | Should be "0.00" Expand-NumberFormat 'Number' | Should -Be "0.00"
Expand-NumberFormat 'Percentage' | Should be "0.00%" Expand-NumberFormat 'Percentage' | Should -Be "0.00%"
Expand-NumberFormat 'Scientific' | Should be "0.00E+00" Expand-NumberFormat 'Scientific' | Should -Be "0.00E+00"
Expand-NumberFormat 'Fraction' | Should be "# ?/?" Expand-NumberFormat 'Fraction' | Should -Be "# ?/?"
Expand-NumberFormat 'Short Date' | Should be "mm-dd-yy" Expand-NumberFormat 'Short Date' | Should -Be "mm-dd-yy"
Expand-NumberFormat 'Short Time' | Should be "h:mm" Expand-NumberFormat 'Short Time' | Should -Be "h:mm"
Expand-NumberFormat 'Long Time' | Should be "h:mm:ss" Expand-NumberFormat 'Long Time' | Should -Be "h:mm:ss"
Expand-NumberFormat 'Date-Time' | Should be "m/d/yy h:mm" Expand-NumberFormat 'Date-Time' | Should -Be "m/d/yy h:mm"
Expand-NumberFormat 'Text' | Should be "@" Expand-NumberFormat 'Text' | Should -Be "@"
} }
} }
Context "Apply-NumberFormat" { Context "Apply-NumberFormat" {
@@ -87,36 +87,36 @@ Describe "Number format expansion and setting" {
} }
It "Set formats which translate to the correct format ID " { It "Set formats which translate to the correct format ID " {
$ws.Cells[ 1, 1].Style.Numberformat.NumFmtID | Should be 0 # Set as General $ws.Cells[ 1, 1].Style.Numberformat.NumFmtID | Should -Be 0 # Set as General
$ws.Cells[20, 1].Style.Numberformat.NumFmtID | Should be 1 # Set as 0 $ws.Cells[20, 1].Style.Numberformat.NumFmtID | Should -Be 1 # Set as 0
$ws.Cells[ 2, 1].Style.Numberformat.NumFmtID | Should be 2 # Set as "Number" $ws.Cells[ 2, 1].Style.Numberformat.NumFmtID | Should -Be 2 # Set as "Number"
$ws.Cells[21, 1].Style.Numberformat.NumFmtID | Should be 2 # Set as 0.00 $ws.Cells[21, 1].Style.Numberformat.NumFmtID | Should -Be 2 # Set as 0.00
$ws.Cells[22, 1].Style.Numberformat.NumFmtID | Should be 3 # Set as #,##0 $ws.Cells[22, 1].Style.Numberformat.NumFmtID | Should -Be 3 # Set as #,##0
$ws.Cells[23, 1].Style.Numberformat.NumFmtID | Should be 4 # Set as #,##0.00 $ws.Cells[23, 1].Style.Numberformat.NumFmtID | Should -Be 4 # Set as #,##0.00
$ws.Cells[26, 1].Style.Numberformat.NumFmtID | Should be 9 # Set as 0% $ws.Cells[26, 1].Style.Numberformat.NumFmtID | Should -Be 9 # Set as 0%
$ws.Cells[27, 1].Style.Numberformat.NumFmtID | Should be 10 # Set as 0.00% $ws.Cells[27, 1].Style.Numberformat.NumFmtID | Should -Be 10 # Set as 0.00%
$ws.Cells[ 3, 1].Style.Numberformat.NumFmtID | Should be 10 # Set as "Percentage" $ws.Cells[ 3, 1].Style.Numberformat.NumFmtID | Should -Be 10 # Set as "Percentage"
$ws.Cells[28, 1].Style.Numberformat.NumFmtID | Should be 11 # Set as 0.00E+00 $ws.Cells[28, 1].Style.Numberformat.NumFmtID | Should -Be 11 # Set as 0.00E+00
$ws.Cells[ 4, 1].Style.Numberformat.NumFmtID | Should be 11 # Set as "Scientific" $ws.Cells[ 4, 1].Style.Numberformat.NumFmtID | Should -Be 11 # Set as "Scientific"
$ws.Cells[ 5, 1].Style.Numberformat.NumFmtID | Should be 12 # Set as "Fraction" $ws.Cells[ 5, 1].Style.Numberformat.NumFmtID | Should -Be 12 # Set as "Fraction"
$ws.Cells[29, 1].Style.Numberformat.NumFmtID | Should be 12 # Set as # ?/? $ws.Cells[29, 1].Style.Numberformat.NumFmtID | Should -Be 12 # Set as # ?/?
$ws.Cells[30, 1].Style.Numberformat.NumFmtID | Should be 13 # Set as # ??/? $ws.Cells[30, 1].Style.Numberformat.NumFmtID | Should -Be 13 # Set as # ??/?
$ws.Cells[ 6, 1].Style.Numberformat.NumFmtID | Should be 14 # Set as "Short date" $ws.Cells[ 6, 1].Style.Numberformat.NumFmtID | Should -Be 14 # Set as "Short date"
$ws.Cells[17, 1].Style.Numberformat.NumFmtID | Should be 15 # Set as d-mmm-yy $ws.Cells[17, 1].Style.Numberformat.NumFmtID | Should -Be 15 # Set as d-mmm-yy
$ws.Cells[18, 1].Style.Numberformat.NumFmtID | Should be 16 # Set as d-mmm $ws.Cells[18, 1].Style.Numberformat.NumFmtID | Should -Be 16 # Set as d-mmm
$ws.Cells[19, 1].Style.Numberformat.NumFmtID | Should be 17 # Set as mmm-yy $ws.Cells[19, 1].Style.Numberformat.NumFmtID | Should -Be 17 # Set as mmm-yy
$ws.Cells[12, 1].Style.Numberformat.NumFmtID | Should be 18 # Set as h:mm AM/PM $ws.Cells[12, 1].Style.Numberformat.NumFmtID | Should -Be 18 # Set as h:mm AM/PM
$ws.Cells[13, 1].Style.Numberformat.NumFmtID | Should be 19 # Set as h:mm:ss AM/PM $ws.Cells[13, 1].Style.Numberformat.NumFmtID | Should -Be 19 # Set as h:mm:ss AM/PM
$ws.Cells[ 7, 1].Style.Numberformat.NumFmtID | Should be 20 # Set as "Short time" $ws.Cells[ 7, 1].Style.Numberformat.NumFmtID | Should -Be 20 # Set as "Short time"
$ws.Cells[ 8, 1].Style.Numberformat.NumFmtID | Should be 21 # Set as "Long time" $ws.Cells[ 8, 1].Style.Numberformat.NumFmtID | Should -Be 21 # Set as "Long time"
$ws.Cells[ 9, 1].Style.Numberformat.NumFmtID | Should be 22 # Set as "Date-time" $ws.Cells[ 9, 1].Style.Numberformat.NumFmtID | Should -Be 22 # Set as "Date-time"
$ws.Cells[14, 1].Style.Numberformat.NumFmtID | Should be 45 # Set as mm:ss $ws.Cells[14, 1].Style.Numberformat.NumFmtID | Should -Be 45 # Set as mm:ss
$ws.Cells[15, 1].Style.Numberformat.NumFmtID | Should be 46 # Set as [h]:mm:ss $ws.Cells[15, 1].Style.Numberformat.NumFmtID | Should -Be 46 # Set as [h]:mm:ss
$ws.Cells[16, 1].Style.Numberformat.NumFmtID | Should be 47 # Set as mmss.0 $ws.Cells[16, 1].Style.Numberformat.NumFmtID | Should -Be 47 # Set as mmss.0
$ws.Cells[11, 1].Style.Numberformat.NumFmtID | Should be 49 # Set as "Text" $ws.Cells[11, 1].Style.Numberformat.NumFmtID | Should -Be 49 # Set as "Text"
$ws.Cells[31, 1].Style.Numberformat.NumFmtID | Should be 49 # Set as @ $ws.Cells[31, 1].Style.Numberformat.NumFmtID | Should -Be 49 # Set as @
$ws.Cells[24, 1].Style.Numberformat.Format | Should be '#,' # Whole thousands $ws.Cells[24, 1].Style.Numberformat.Format | Should -Be '#,' # Whole thousands
$ws.Cells[25, 1].Style.Numberformat.Format | Should be '#.0,,' # Millions $ws.Cells[25, 1].Style.Numberformat.Format | Should -Be '#.0,,' # Millions
} }
} }
} }
@@ -155,70 +155,70 @@ Describe "Set-ExcelColumn, Set-ExcelRow and Set-ExcelRange" {
} }
Context "Set-ExcelRow and Set-ExcelColumn" { Context "Set-ExcelRow and Set-ExcelColumn" {
it "Set a row and a column to have zero width/height " { it "Set a row and a column to have zero width/height " {
$r | Should not beNullorEmpty $r | Should -Not -BeNullorEmpty
# $c | Should not beNullorEmpty ## can't see why but this test breaks in appveyor # $c | Should -Not -BeNullorEmpty ## can't see why but this test breaks in appveyor
$ws.Column(1).width | Should be 0 $ws.Column(1).width | Should -Be 0
$ws.Row(5).height | Should be 0 $ws.Row(5).height | Should -Be 0
} }
it "Set a column formula, with numberformat, color, bold face and alignment " { it "Set a column formula, with numberformat, color, bold face and alignment " {
$ws.Cells["e2"].Formula | Should be "Quantity*Price" $ws.Cells["e2"].Formula | Should -Be "Quantity*Price"
$ws.Cells["e2"].Value | Should be 147.63 $ws.Cells["e2"].Value | Should -Be 147.63
$ws.Cells["e2"].Style.Font.Color.rgb | Should be "FF0000FF" $ws.Cells["e2"].Style.Font.Color.rgb | Should -Be "FF0000FF"
$ws.Cells["e2"].Style.Font.Bold | Should be $true $ws.Cells["e2"].Style.Font.Bold | Should -Be $true
$ws.Cells["e2"].Style.Font.VerticalAlign | Should be "None" $ws.Cells["e2"].Style.Font.VerticalAlign | Should -Be "None"
$ws.Cells["e2"].Style.Numberformat.format | Should be "£#,###.00" $ws.Cells["e2"].Style.Numberformat.format | Should -Be "£#,###.00"
$ws.Cells["e2"].Style.HorizontalAlignment | Should be "Right" $ws.Cells["e2"].Style.HorizontalAlignment | Should -Be "Right"
} }
} }
Context "Other formatting" { Context "Other formatting" {
it "Trapped an attempt to hide a range instead of a Row/Column " { it "Trapped an attempt to hide a range instead of a Row/Column " {
$BadHideWarnvar | Should not beNullOrEmpty $BadHideWarnvar | Should -Not -BeNullOrEmpty
} }
it "Set and calculated a row formula with border font size and underline " { it "Set and calculated a row formula with border font size and underline " {
$ws.Cells["b7"].Style.Border.Top.Style | Should be "None" $ws.Cells["b7"].Style.Border.Top.Style | Should -Be "None"
$ws.Cells["F7"].Style.Border.Top.Style | Should be "None" $ws.Cells["F7"].Style.Border.Top.Style | Should -Be "None"
$ws.Cells["C7"].Style.Border.Top.Style | Should be "Thin" $ws.Cells["C7"].Style.Border.Top.Style | Should -Be "Thin"
$ws.Cells["C7"].Style.Border.Bottom.Style | Should be "Thin" $ws.Cells["C7"].Style.Border.Bottom.Style | Should -Be "Thin"
$ws.Cells["C7"].Style.Border.Right.Style | Should be "None" $ws.Cells["C7"].Style.Border.Right.Style | Should -Be "None"
$ws.Cells["C7"].Style.Border.Left.Style | Should be "Thin" $ws.Cells["C7"].Style.Border.Left.Style | Should -Be "Thin"
$ws.Cells["E7"].Style.Border.Left.Style | Should be "None" $ws.Cells["E7"].Style.Border.Left.Style | Should -Be "None"
$ws.Cells["E7"].Style.Border.Right.Style | Should be "Thin" $ws.Cells["E7"].Style.Border.Right.Style | Should -Be "Thin"
$ws.Cells["C7"].Style.Font.size | Should be 14 $ws.Cells["C7"].Style.Font.size | Should -Be 14
$ws.Cells["C7"].Formula | Should be "sum(C2:C6)" $ws.Cells["C7"].Formula | Should -Be "sum(C2:C6)"
$ws.Cells["C7"].value | Should be 81 $ws.Cells["C7"].value | Should -Be 81
$ws.Cells["C7"].Style.Font.UnderLine | Should be $true $ws.Cells["C7"].Style.Font.UnderLine | Should -Be $true
$ws.Cells["C6"].Style.Font.UnderLine | Should be $false $ws.Cells["C6"].Style.Font.UnderLine | Should -Be $false
} }
it "Set custom font, size, text-wrapping, alignment, superscript, border and Fill " { it "Set custom font, size, text-wrapping, alignment, superscript, border and Fill " {
$ws.Cells["b3"].Style.Border.Left.Color.Rgb | Should be "FFFF0000" $ws.Cells["b3"].Style.Border.Left.Color.Rgb | Should -Be "FFFF0000"
$ws.Cells["b3"].Style.Border.Left.Style | Should be "Thick" $ws.Cells["b3"].Style.Border.Left.Style | Should -Be "Thick"
$ws.Cells["b3"].Style.Border.Right.Style | Should be "Thick" $ws.Cells["b3"].Style.Border.Right.Style | Should -Be "Thick"
$ws.Cells["b3"].Style.Border.Top.Style | Should be "Thick" $ws.Cells["b3"].Style.Border.Top.Style | Should -Be "Thick"
$ws.Cells["b3"].Style.Border.Bottom.Style | Should be "Thick" $ws.Cells["b3"].Style.Border.Bottom.Style | Should -Be "Thick"
$ws.Cells["b3"].Style.Font.Strike | Should be $true $ws.Cells["b3"].Style.Font.Strike | Should -Be $true
$ws.Cells["e1"].Style.Font.Color.Rgb | Should be "ff000000" $ws.Cells["e1"].Style.Font.Color.Rgb | Should -Be "ff000000"
$ws.Cells["e1"].Style.Font.Bold | Should be $false $ws.Cells["e1"].Style.Font.Bold | Should -Be $false
$ws.Cells["e1"].Style.Font.Name | Should be "Courier New" $ws.Cells["e1"].Style.Font.Name | Should -Be "Courier New"
$ws.Cells["e1"].Style.Font.Size | Should be 9 $ws.Cells["e1"].Style.Font.Size | Should -Be 9
$ws.Cells["e3"].Style.Font.VerticalAlign | Should be "Superscript" $ws.Cells["e3"].Style.Font.VerticalAlign | Should -Be "Superscript"
$ws.Cells["e3"].Style.HorizontalAlignment | Should be "Left" $ws.Cells["e3"].Style.HorizontalAlignment | Should -Be "Left"
$ws.Cells["C6"].Style.WrapText | Should be $false $ws.Cells["C6"].Style.WrapText | Should -Be $false
$ws.Cells["e7"].Style.WrapText | Should be $true $ws.Cells["e7"].Style.WrapText | Should -Be $true
$ws.Cells["e7"].Style.Fill.BackgroundColor.Rgb | Should be "FFF0F8FF" $ws.Cells["e7"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFF0F8FF"
$ws.Cells["e7"].Style.Fill.PatternColor.Rgb | Should be "FFFF0000" $ws.Cells["e7"].Style.Fill.PatternColor.Rgb | Should -Be "FFFF0000"
$ws.Cells["e7"].Style.Fill.PatternType | Should be "DarkTrellis" $ws.Cells["e7"].Style.Fill.PatternType | Should -Be "DarkTrellis"
} }
} }
Context "Set-ExcelRange value setting " { Context "Set-ExcelRange value setting " {
it "Inserted a formula " { it "Inserted a formula " {
$ws.Cells["D7"].Formula | Should be "E7/C7" $ws.Cells["D7"].Formula | Should -Be "E7/C7"
} }
it "Inserted a value " { it "Inserted a value " {
$ws.Cells["B7"].Value | Should be "Total" $ws.Cells["B7"].Value | Should -Be "Total"
} }
it "Inserted a date with localized date-time format " { it "Inserted a date with localized date-time format " {
$ws.Cells["B8"].Style.Numberformat.NumFmtID | Should be 22 $ws.Cells["B8"].Style.Numberformat.NumFmtID | Should -Be 22
} }
} }
@@ -249,27 +249,27 @@ Describe "Set-ExcelColumn, Set-ExcelRow and Set-ExcelRange" {
$ws = $excel.Workbook.Worksheets["Sheet1"] $ws = $excel.Workbook.Worksheets["Sheet1"]
} }
It "Inserted Hyperlinks " { It "Inserted Hyperlinks " {
$ws.Cells["D2"].Hyperlink | Should not beNullorEmpty $ws.Cells["D2"].Hyperlink | Should -Not -BeNullorEmpty
$ws.Cells["D2"].Style.Font.UnderLine | Should be $true $ws.Cells["D2"].Style.Font.UnderLine | Should -Be $true
} }
It "Inserted and formatted Dates " { It "Inserted and formatted Dates " {
$ws.Cells["C2"].Value.GetType().name | should be "DateTime" $ws.Cells["C2"].Value.GetType().name | Should -Be "DateTime"
$ws.Cells["C2"].Style.Numberformat.NumFmtID | should be 14 $ws.Cells["C2"].Style.Numberformat.NumFmtID | Should -Be 14
$ws.Cells["E2"].Value.GetType().name | should be "DateTime" $ws.Cells["E2"].Value.GetType().name | Should -Be "DateTime"
$ws.Cells["E2"].Style.Numberformat.NumFmtID | should be 14 $ws.Cells["E2"].Style.Numberformat.NumFmtID | Should -Be 14
} }
It "Inserted Formulas " { It "Inserted Formulas " {
$ws.Cells["F2"].Formula | Should not beNullorEmpty $ws.Cells["F2"].Formula | Should -Not -BeNullorEmpty
} }
It "Created Named ranges " { It "Created Named ranges " {
$ws.Names.Count | Should be 6 $ws.Names.Count | Should -Be 6
$ws.Names["Age"] | Should not beNullorEmpty $ws.Names["Age"] | Should -Not -BeNullorEmpty
$ws.Names["Age"].Start.Column | Should be 6 $ws.Names["Age"].Start.Column | Should -Be 6
$ws.Names["Age"].Start.Row | Should be 2 $ws.Names["Age"].Start.Row | Should -Be 2
$ws.Names["Age"].End.Row | Should be 7 $ws.Names["Age"].End.Row | Should -Be 7
$ws.names[0].name | Should be "Name" $ws.names[0].name | Should -Be "Name"
$ws.Names[0].Start.Column | Should be 1 $ws.Names[0].Start.Column | Should -Be 1
$ws.Names[0].Start.Row | Should be 2 $ws.Names[0].Start.Row | Should -Be 2
} }
} }
@@ -286,9 +286,9 @@ Describe "Conditional Formatting" {
} }
Context "Using a pre-prepared 3 Arrows rule" { Context "Using a pre-prepared 3 Arrows rule" {
it "Set the right type, IconSet and range " { it "Set the right type, IconSet and range " {
$ws.ConditionalFormatting[0].IconSet | Should be "Arrows" $ws.ConditionalFormatting[0].IconSet | Should -Be "Arrows"
$ws.ConditionalFormatting[0].Address.Address | Should be "c:c" $ws.ConditionalFormatting[0].Address.Address | Should -Be "c:c"
$ws.ConditionalFormatting[0].Type.ToString() | Should be "ThreeIconSet" $ws.ConditionalFormatting[0].Type.ToString() | Should -Be "ThreeIconSet"
} }
} }
@@ -329,8 +329,8 @@ Sold
$ws = $excel.Workbook.Worksheets["Sheet1"] $ws = $excel.Workbook.Worksheets["Sheet1"]
$ws.Names.Count | Should Be 1 $ws.Names.Count | Should -Be 1
$ws.Names[0].Name | Should Be 'Sold' $ws.Names[0].Name | Should -Be 'Sold'
} }
it "Should have a more than a single item as a named range " { it "Should have a more than a single item as a named range " {
@@ -344,9 +344,9 @@ Sold,ID
$ws = $excel.Workbook.Worksheets["Sheet1"] $ws = $excel.Workbook.Worksheets["Sheet1"]
$ws.Names.Count | Should Be 2 $ws.Names.Count | Should -Be 2
$ws.Names[0].Name | Should Be 'Sold' $ws.Names[0].Name | Should -Be 'Sold'
$ws.Names[1].Name | Should Be 'ID' $ws.Names[1].Name | Should -Be 'ID'
} }
} }
@@ -368,20 +368,20 @@ Describe "Table Formatting" {
} }
Context "Setting and not clearing when Export-Excel touches the file again." { Context "Setting and not clearing when Export-Excel touches the file again." {
it "Set the Table Options " { it "Set the Table Options " {
$ws1.Tables[0].Address.Address | should be "A1:E16" $ws1.Tables[0].Address.Address | Should -Be "A1:E16"
$ws1.Tables[0].Name | should be "HardwareTable" $ws1.Tables[0].Name | Should -Be "HardwareTable"
$ws1.Tables[0].ShowFirstColumn | should be $true $ws1.Tables[0].ShowFirstColumn | Should -Be $true
$ws1.Tables[0].ShowLastColumn | should not be $true $ws1.Tables[0].ShowLastColumn | Should -Not -Be $true
$ws1.Tables[0].ShowTotal | should be $true $ws1.Tables[0].ShowTotal | Should -Be $true
$ws1.Tables[0].Columns["Total"].TotalsRowFunction | Should be "Sum" $ws1.Tables[0].Columns["Total"].TotalsRowFunction | Should -Be "Sum"
$ws1.Tables[0].StyleName | should be "TableStyleLight1" $ws1.Tables[0].StyleName | Should -Be "TableStyleLight1"
$ws1.Cells["D4"].Style.Numberformat.Format | Should match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol)) $ws1.Cells["D4"].Style.Numberformat.Format | Should -Match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
$ws1.Cells["E5"].Style.Numberformat.Format | Should match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol)) $ws1.Cells["E5"].Style.Numberformat.Format | Should -Match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
} }
it "Set the Pivot Options " { it "Set the Pivot Options " {
$ws2.PivotTables[0].DataFields[0].Format | Should match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol)) $ws2.PivotTables[0].DataFields[0].Format | Should -Match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
$ws2.PivotTables[0].ColumGrandTotals | Should be $false $ws2.PivotTables[0].ColumGrandTotals | Should -Be $false
$ws2.PivotTables[0].StyleName | Should be "PivotStyleDark2" $ws2.PivotTables[0].StyleName | Should -Be "PivotStyleDark2"
} }
} }
} }

View File

@@ -28,30 +28,30 @@ Describe "Data validation and protection" {
$ws = $excelPackage.Sales $ws = $excelPackage.Sales
} }
It "Created the expected number of rules " { It "Created the expected number of rules " {
$ws.DataValidations.count | Should be 2 $ws.DataValidations.count | Should -Be 2
} }
It "Created a List validation rule against a range of Cells " { It "Created a List validation rule against a range of Cells " {
$ws.DataValidations[0].ValidationType.Type.tostring() | Should be 'List' $ws.DataValidations[0].ValidationType.Type.tostring() | Should -Be 'List'
$ws.DataValidations[0].Formula.ExcelFormula | Should be 'values!$a$1:$a$10' $ws.DataValidations[0].Formula.ExcelFormula | Should -Be 'values!$a$1:$a$10'
$ws.DataValidations[0].Formula2 | Should benullorempty $ws.DataValidations[0].Formula2 | Should -Benullorempty
} }
It "Created an integer validation rule for values between X and Y " { It "Created an integer validation rule for values between X and Y " {
$ws.DataValidations[1].ValidationType.Type.tostring() | Should be 'Whole' $ws.DataValidations[1].ValidationType.Type.tostring() | Should -Be 'Whole'
$ws.DataValidations[1].Formula.Value | Should be 0 $ws.DataValidations[1].Formula.Value | Should -Be 0
$ws.DataValidations[1].Formula2.value | Should not benullorempty $ws.DataValidations[1].Formula2.value | Should -Not -Benullorempty
$ws.DataValidations[1].Operator.tostring() | should be 'between' $ws.DataValidations[1].Operator.tostring() | Should -Be 'between'
} }
It "Set Error behaviors for both rules " { It "Set Error behaviors for both rules " {
$ws.DataValidations[0].ErrorStyle.tostring() | Should be 'stop' $ws.DataValidations[0].ErrorStyle.tostring() | Should -Be 'stop'
$ws.DataValidations[1].ErrorStyle.tostring() | Should be 'stop' $ws.DataValidations[1].ErrorStyle.tostring() | Should -Be 'stop'
$ws.DataValidations[0].AllowBlank | Should be $true $ws.DataValidations[0].AllowBlank | Should -Be $true
$ws.DataValidations[1].AllowBlank | Should be $true $ws.DataValidations[1].AllowBlank | Should -Be $true
$ws.DataValidations[0].ShowErrorMessage | Should be $true $ws.DataValidations[0].ShowErrorMessage | Should -Be $true
$ws.DataValidations[1].ShowErrorMessage | Should be $true $ws.DataValidations[1].ShowErrorMessage | Should -Be $true
$ws.DataValidations[0].ErrorTitle | Should not benullorempty $ws.DataValidations[0].ErrorTitle | Should -Not -Benullorempty
$ws.DataValidations[1].ErrorTitle | Should not benullorempty $ws.DataValidations[1].ErrorTitle | Should -Not -Benullorempty
$ws.DataValidations[0].Error | Should not benullorempty $ws.DataValidations[0].Error | Should -Not -Benullorempty
$ws.DataValidations[1].Error | Should not benullorempty $ws.DataValidations[1].Error | Should -Not -Benullorempty
} }
} }

View File

@@ -6576,6 +6576,346 @@ Boston,2/18/2018,1000
<command:examples /> <command:examples />
<command:relatedLinks /> <command:relatedLinks />
</command:command> </command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details>
<command:name>ConvertFrom-ExcelSheet</command:name>
<command:verb>ConvertFrom</command:verb>
<command:noun>ExcelSheet</command:noun>
<maml:description>
<maml:para>Exports Sheets from Excel Workbooks to CSV files.</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>This command provides a convenient way to run Import-Excel @ImportParameters | Select-Object @selectParameters | export-Csv @ ExportParameters It can take the parameters -AsText , as used in Import-Excel, )Properties &amp; -ExcludeProperties as used in Select-Object and -Append, -Delimiter and -Encoding as used in Export-CSV</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>ConvertFrom-ExcelSheet</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none">
<maml:name>Path</maml:name>
<maml:Description>
<maml:para>The path to the .XLSX file which will be exported.</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>OutputPath</maml:name>
<maml:Description>
<maml:para>The directory where the output file(s) will be created. The file name(s) will match the name of the workbook page which contained the data.</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none">
<maml:name>SheetName</maml:name>
<maml:Description>
<maml:para>The name of a sheet to export, or a regular expression which is used to identify sheets</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none">
<maml:name>Encoding</maml:name>
<maml:Description>
<maml:para>Sets the text encoding for the output data file; UTF8 bu default</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue>
<dev:type>
<maml:name>Encoding</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="4" aliases="none">
<maml:name>Extension</maml:name>
<maml:Description>
<maml:para>Sets the file extension for the exported data, defaults to CSV</maml:para>
</maml:Description>
<command:parameterValueGroup>
<command:parameterValue required="false" command:variableLength="false">.txt</command:parameterValue>
<command:parameterValue required="false" command:variableLength="false">.log</command:parameterValue>
<command:parameterValue required="false" command:variableLength="false">.csv</command:parameterValue>
</command:parameterValueGroup>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="5" aliases="none">
<maml:name>Delimiter</maml:name>
<maml:Description>
<maml:para>Selects , or ; as the delimeter for the exported data - if not specified , is used by default.</maml:para>
</maml:Description>
<command:parameterValueGroup>
<command:parameterValue required="false" command:variableLength="false">;</command:parameterValue>
<command:parameterValue required="false" command:variableLength="false"></command:parameterValue>
<command:parameterValue required="false" command:variableLength="false"></command:parameterValue>
</command:parameterValueGroup>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="6" aliases="none">
<maml:name>Property</maml:name>
<maml:Description>
<maml:para>Specifies the properties to select. Wildcards are permitted - the default is "*". The value of the Property parameter can be a new calculated property, and follows the same pattern as Select-Item</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
<dev:type>
<maml:name>Object</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="7" aliases="none">
<maml:name>ExcludeProperty</maml:name>
<maml:Description>
<maml:para>Specifies the properties that to exclude from the export. Wildcards are permitted. This parameter is effective only when the command also includes the Property parameter.</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
<dev:type>
<maml:name>Object</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="8" aliases="none">
<maml:name>AsText</maml:name>
<maml:Description>
<maml:para>AsText allows selected columns to be returned as the text displayed in their cells, instead of their value. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="8" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Append</maml:name>
<maml:Description>
<maml:para>Use this parameter to have the export add output to the end of the file. Without this parameter, the command replaces the file contents without warning.</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Append</maml:name>
<maml:Description>
<maml:para>Use this parameter to have the export add output to the end of the file. Without this parameter, the command replaces the file contents without warning.</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="8" aliases="none">
<maml:name>AsText</maml:name>
<maml:Description>
<maml:para>AsText allows selected columns to be returned as the text displayed in their cells, instead of their value. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="8" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="5" aliases="none">
<maml:name>Delimiter</maml:name>
<maml:Description>
<maml:para>Selects , or ; as the delimeter for the exported data - if not specified , is used by default.</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none">
<maml:name>Encoding</maml:name>
<maml:Description>
<maml:para>Sets the text encoding for the output data file; UTF8 bu default</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue>
<dev:type>
<maml:name>Encoding</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="7" aliases="none">
<maml:name>ExcludeProperty</maml:name>
<maml:Description>
<maml:para>Specifies the properties that to exclude from the export. Wildcards are permitted. This parameter is effective only when the command also includes the Property parameter.</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
<dev:type>
<maml:name>Object</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="4" aliases="none">
<maml:name>Extension</maml:name>
<maml:Description>
<maml:para>Sets the file extension for the exported data, defaults to CSV</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>OutputPath</maml:name>
<maml:Description>
<maml:para>The directory where the output file(s) will be created. The file name(s) will match the name of the workbook page which contained the data.</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none">
<maml:name>Path</maml:name>
<maml:Description>
<maml:para>The path to the .XLSX file which will be exported.</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="6" aliases="none">
<maml:name>Property</maml:name>
<maml:Description>
<maml:para>Specifies the properties to select. Wildcards are permitted - the default is "*". The value of the Property parameter can be a new calculated property, and follows the same pattern as Select-Item</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
<dev:type>
<maml:name>Object</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none">
<maml:name>SheetName</maml:name>
<maml:Description>
<maml:para>The name of a sheet to export, or a regular expression which is used to identify sheets</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Object</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:alertSet>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------------------- Example 1 --------------------------</maml:title>
<dev:code>PS C:\&gt; ConvertFrom-ExcelSheet Path .\__tests__\First10Races.xlsx -OutputPath .. -AsText GridPosition,date</dev:code>
<dev:remarks>
<maml:para>First10Races.xlsx contains information about Motor races. The race date and grid (starting) position are stored with custom formats. The command specifies the path to the file, and the directory to create the output file, and specifies that the columns "GridPosition" and "Date" should be treated as text to preserve their formatting</maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- Example 2 --------------------------</maml:title>
<dev:code>PS C:\&gt; ConvertFrom-ExcelSheet Path .\__tests__\First10Races.xlsx -OutputPath .. -AsText "GridPosition" -Property driver, @{n="date"; e={[datetime]::FromOADate($_.Date).tostring("#MM/dd/yyyy#")}} , FinishPosition, GridPosition</dev:code>
<dev:remarks>
<maml:para>This uses the same file as example 1. Because the race date has a custom format, it imports as a number, The requirement is to create a CSV file with the Driver, a specially formatted Date, FinishPostion and GridPostion (keeping its custom formatting). The command specifies the path to the file, and the directory to create the output file, specifies that the column "GridPosition" should be treated as text instead of a number, and the output properties should be Driver, a calculated "date" field, FinishPosition and GridPsition. FromOADate converts the dates used by Excel (Days since Jan 1 1900) to a datetime object.</maml:para>
</dev:remarks>
</command:example>
</command:examples>
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online Version:</maml:linkText>
<maml:uri>https://github.com/dfinke/ImportExcel</maml:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details> <command:details>
<command:name>ConvertFrom-ExcelToSQLInsert</command:name> <command:name>ConvertFrom-ExcelToSQLInsert</command:name>
@@ -10499,6 +10839,18 @@ PS\&gt; Export-Excel -ExcelPackage $excel -WorksheetName "Processes" -IncludePiv
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Password</maml:name> <maml:name>Password</maml:name>
<maml:Description> <maml:Description>
@@ -10624,6 +10976,18 @@ PS\&gt; Export-Excel -ExcelPackage $excel -WorksheetName "Processes" -IncludePiv
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Password</maml:name> <maml:name>Password</maml:name>
<maml:Description> <maml:Description>
@@ -10735,6 +11099,18 @@ PS\&gt; Export-Excel -ExcelPackage $excel -WorksheetName "Processes" -IncludePiv
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Password</maml:name> <maml:name>Password</maml:name>
<maml:Description> <maml:Description>
@@ -10859,6 +11235,18 @@ PS\&gt; Export-Excel -ExcelPackage $excel -WorksheetName "Processes" -IncludePiv
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Password</maml:name> <maml:name>Password</maml:name>
<maml:Description> <maml:Description>
@@ -10985,6 +11373,18 @@ PS\&gt; Export-Excel -ExcelPackage $excel -WorksheetName "Processes" -IncludePiv
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Password</maml:name> <maml:name>Password</maml:name>
<maml:Description> <maml:Description>
@@ -11097,6 +11497,18 @@ PS\&gt; Export-Excel -ExcelPackage $excel -WorksheetName "Processes" -IncludePiv
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Password</maml:name> <maml:name>Password</maml:name>
<maml:Description> <maml:Description>
@@ -11249,6 +11661,18 @@ PS\&gt; Export-Excel -ExcelPackage $excel -WorksheetName "Processes" -IncludePiv
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AsDate</maml:name>
<maml:Description>
<maml:para>Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Password</maml:name> <maml:name>Password</maml:name>
<maml:Description> <maml:Description>

4
mdHelp/buildHelp.ps1 Normal file
View File

@@ -0,0 +1,4 @@
Import-Module platyPS
Get-ChildItem $PSScriptRoot -Directory | ForEach-Object {
New-ExternalHelp -Path $_.FullName -OutputPath (Join-Path $PSScriptRoot "..\$($_.Name)") -Force -Verbose
}

View File

@@ -76,6 +76,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -AsDate
Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Delimiter ### -Delimiter
Selects , or ; as the delimeter for the exported data - if not specified , is used by default. Selects , or ; as the delimeter for the exported data - if not specified , is used by default.

View File

@@ -395,6 +395,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -AsDate
Not all date formats are recognized as indicating the number in the cell represents a date AsDate forces the number which would be returned to be converted to a date. (* is supported as a wildcard.)
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Password ### -Password
Accepts a string that will be used to open a password protected Excel file. Accepts a string that will be used to open a password protected Excel file.

View File

@@ -194,7 +194,7 @@ Accept wildcard characters: False
``` ```
### -GroupDateRow ### -GroupDateRow
The name of a row field which should be grouped by parts of the date/time (ignored if GroupDateRow is not specified) The name of a row field which should be grouped by parts of the date/time (ignored if GroupDatePart is not specified)
```yaml ```yaml
Type: String Type: String