mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-15 15:53:32 +00:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bb3d50052 | ||
|
|
d5b807d3cb | ||
|
|
e2053e4998 | ||
|
|
8c6c7eeaf6 | ||
|
|
31abd215dc | ||
|
|
cafaafd53d | ||
|
|
ee3c8e7680 | ||
|
|
0b207548e0 | ||
|
|
6628b55ce5 | ||
|
|
f6bfabd96a | ||
|
|
980631df8b | ||
|
|
4f9b83f0e6 | ||
|
|
59cf89b451 | ||
|
|
5777d907c4 | ||
|
|
d7c516d35e | ||
|
|
27d69e7531 | ||
|
|
8ae92fba54 | ||
|
|
aa0f0cf4e2 | ||
|
|
6e38d97498 | ||
|
|
ef7c8331f5 | ||
|
|
267d15f99a | ||
|
|
390aca0496 | ||
|
|
4fa34ae257 | ||
|
|
0b3b382c4e | ||
|
|
415be5bca3 | ||
|
|
79e5bdf8ba | ||
|
|
b03d9b048a | ||
|
|
aea90aa8d6 | ||
|
|
d4ebc9e95d | ||
|
|
6ece4483e2 | ||
|
|
ba14511254 | ||
|
|
964cf9e9c6 | ||
|
|
8d56a351ff | ||
|
|
b2119f08f5 | ||
|
|
634aaacc55 | ||
|
|
61b44f826d | ||
|
|
9273261b34 | ||
|
|
e55dfdd10e | ||
|
|
59e40d62d0 | ||
|
|
f478e8a134 | ||
|
|
b634bf9d93 | ||
|
|
a10ade898a | ||
|
|
eb10364722 | ||
|
|
b0024cf2c4 | ||
|
|
7f36b44fa8 | ||
|
|
483f761016 | ||
|
|
d55f0e64d4 | ||
|
|
f83f654c4a | ||
|
|
6a956dbd7e |
23
Examples/CustomNumbers/ShortenNumbers.ps1
Normal file
23
Examples/CustomNumbers/ShortenNumbers.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
# How to convert abbreviate or shorten long numbers in Excel
|
||||
|
||||
Remove-Item .\custom.xlsx -ErrorAction SilentlyContinue
|
||||
|
||||
$data = $(
|
||||
12000
|
||||
1000
|
||||
2000
|
||||
3000
|
||||
2400
|
||||
3600
|
||||
6000
|
||||
13000
|
||||
40000
|
||||
400000
|
||||
1000000
|
||||
)
|
||||
|
||||
$excel = $data | Export-Excel .\custom.xlsx -PassThru
|
||||
|
||||
Set-ExcelRange -Worksheet $excel.Sheet1 -Range "A:A" -NumberFormat '[>999999]#,,"M";#,"K"'
|
||||
|
||||
Close-ExcelPackage $excel -Show
|
||||
7
Examples/Import-Excel/ImportMultipleSheetsAsArray.ps1
Normal file
7
Examples/Import-Excel/ImportMultipleSheetsAsArray.ps1
Normal file
@@ -0,0 +1,7 @@
|
||||
Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
|
||||
|
||||
$xlfile = "$PSScriptRoot\yearlySales.xlsx"
|
||||
|
||||
$result = Import-Excel -Path $xlfile -WorksheetName * -Raw
|
||||
|
||||
$result | Measure-Object
|
||||
@@ -0,0 +1,9 @@
|
||||
Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
|
||||
|
||||
$xlfile = "$PSScriptRoot\yearlySales.xlsx"
|
||||
|
||||
$result = Import-Excel -Path $xlfile -WorksheetName *
|
||||
|
||||
foreach ($sheet in $result.Values) {
|
||||
$sheet
|
||||
}
|
||||
BIN
Examples/Import-Excel/yearlySales.xlsx
Normal file
BIN
Examples/Import-Excel/yearlySales.xlsx
Normal file
Binary file not shown.
28
Examples/OpenExcelPackage/EnableFeatures.ps1
Normal file
28
Examples/OpenExcelPackage/EnableFeatures.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
# How to use Enable-ExcelAutoFilter and Enable-ExcelAutofit
|
||||
|
||||
try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return }
|
||||
|
||||
$data = ConvertFrom-Csv @"
|
||||
RegionInfo,StateInfo,Units,Price
|
||||
West,Texas,927,923.71
|
||||
North,Tennessee,466,770.67
|
||||
East,Florida,520,458.68
|
||||
East,Maine,828,661.24
|
||||
West,Virginia,465,053.58
|
||||
North,Missouri,436,235.67
|
||||
South,Kansas,214,992.47
|
||||
North,North Dakota,789,640.72
|
||||
South,Delaware,712,508.55
|
||||
"@
|
||||
|
||||
$xlfile = "$PSScriptRoot\enableFeatures.xlsx"
|
||||
Remove-Item $xlfile -ErrorAction SilentlyContinue
|
||||
|
||||
$data | Export-Excel $xlfile
|
||||
|
||||
$excel = Open-ExcelPackage $xlfile
|
||||
|
||||
Enable-ExcelAutoFilter -Worksheet $excel.Sheet1
|
||||
Enable-ExcelAutofit -Worksheet $excel.Sheet1
|
||||
|
||||
Close-ExcelPackage $excel -Show
|
||||
@@ -6,7 +6,7 @@
|
||||
RootModule = 'ImportExcel.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '7.4.2'
|
||||
ModuleVersion = '7.5.3'
|
||||
|
||||
# ID used to uniquely identify this module
|
||||
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
|
||||
@@ -48,11 +48,14 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
||||
'ConvertTo-ExcelXlsx',
|
||||
'Copy-ExcelWorksheet',
|
||||
'DoChart',
|
||||
'Enable-ExcelAutoFilter',
|
||||
'Enable-ExcelAutofit',
|
||||
'Expand-NumberFormat',
|
||||
'Export-Excel',
|
||||
'Export-ExcelSheet',
|
||||
'Get-ExcelColumnName',
|
||||
'Get-ExcelFileSummary',
|
||||
'Get-ExcelSheetDimensionAddress',
|
||||
'Get-ExcelSheetInfo',
|
||||
'Get-ExcelWorkbookInfo',
|
||||
'Get-HtmlTable',
|
||||
@@ -63,8 +66,8 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
||||
'Import-UPS',
|
||||
'Import-USPS',
|
||||
'Invoke-AllTests',
|
||||
'Invoke-Sum',
|
||||
'Invoke-ExcelQuery',
|
||||
'Invoke-Sum',
|
||||
'Join-Worksheet',
|
||||
'LineChart',
|
||||
'Merge-MultipleSheets',
|
||||
@@ -80,8 +83,8 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
||||
'PieChart',
|
||||
'Pivot',
|
||||
'Read-Clipboard',
|
||||
'ReadClipboardImpl',
|
||||
'Read-OleDbData',
|
||||
'ReadClipboardImpl',
|
||||
'Remove-Worksheet',
|
||||
'Select-Worksheet',
|
||||
'Send-SQLDataToExcel',
|
||||
@@ -128,9 +131,8 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
||||
'.\Charting\Charting.ps1',
|
||||
'.\InferData\InferData.ps1',
|
||||
'.\Pivot\Pivot.ps1',
|
||||
'.\spikes\ConvertFrom-ExcelColumnName.ps1',
|
||||
'.\Examples', '.\images', '.\Testimonials'
|
||||
|
||||
'.\Examples',
|
||||
'.\Testimonials'
|
||||
)
|
||||
|
||||
# Private data to pass to the module specified in RootModule/ModuleToProcess
|
||||
|
||||
@@ -7,5 +7,5 @@ if (-not $fullPath) {
|
||||
$fullPath = Join-Path $fullPath -ChildPath "ImportExcel"
|
||||
}
|
||||
Push-location $PSScriptRoot
|
||||
Robocopy . $fullPath /mir /XD .vscode .git CI __tests__ data mdHelp /XF appveyor.yml azure-pipelines.yml .gitattributes .gitignore filelist.txt install.ps1 InstallModule.ps1
|
||||
Robocopy . $fullPath /mir /XD .vscode images .git .github CI __tests__ data mdHelp spikes /XF README.md README.original.md appveyor.yml azure-pipelines.yml .gitattributes .gitignore filelist.txt install.ps1 InstallModule.ps1 PublishToGallery.ps1
|
||||
Pop-Location
|
||||
16
Public/Enable-ExcelAutoFilter.ps1
Normal file
16
Public/Enable-ExcelAutoFilter.ps1
Normal file
@@ -0,0 +1,16 @@
|
||||
function Enable-ExcelAutoFilter {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Enable the Excel AutoFilter
|
||||
|
||||
.EXAMPLE
|
||||
Enable-ExcelAutoFilter $targetSheet
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[OfficeOpenXml.ExcelWorksheet]$Worksheet
|
||||
)
|
||||
|
||||
$range = Get-ExcelSheetDimensionAddress $Worksheet
|
||||
$Worksheet.Cells[$range].AutoFilter = $true
|
||||
}
|
||||
16
Public/Enable-ExcelAutofit.ps1
Normal file
16
Public/Enable-ExcelAutofit.ps1
Normal file
@@ -0,0 +1,16 @@
|
||||
function Enable-ExcelAutofit {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Make all text fit the cells
|
||||
|
||||
.EXAMPLE
|
||||
Enable-ExcelAutofit $excel.Sheet1
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[OfficeOpenXml.ExcelWorksheet]$Worksheet
|
||||
)
|
||||
|
||||
$range = Get-ExcelSheetDimensionAddress $Worksheet
|
||||
$Worksheet.Cells[$range].AutoFitColumns()
|
||||
}
|
||||
15
Public/Get-ExcelSheetDimensionAddress.ps1
Normal file
15
Public/Get-ExcelSheetDimensionAddress.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
function Get-ExcelSheetDimensionAddress {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Get the Excel address of the dimension of a sheet
|
||||
|
||||
.EXAMPLE
|
||||
Get-ExcelSheetDimensionAddress $excel.Sheet1
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[OfficeOpenXml.ExcelWorksheet]$Worksheet
|
||||
)
|
||||
|
||||
$Worksheet.Dimension.Address
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
[Alias('Sheet')]
|
||||
[Parameter(Position = 1)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$WorksheetName,
|
||||
[String[]]$WorksheetName,
|
||||
[Parameter(ParameterSetName = 'PathB' , Mandatory)]
|
||||
[Parameter(ParameterSetName = 'PackageB', Mandatory)]
|
||||
[String[]]$HeaderName ,
|
||||
@@ -36,7 +36,8 @@
|
||||
[string[]]$AsDate,
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$Password,
|
||||
[Int[]]$ImportColumns
|
||||
[Int[]]$ImportColumns,
|
||||
[Switch]$Raw
|
||||
)
|
||||
end {
|
||||
$sw = [System.Diagnostics.Stopwatch]::StartNew()
|
||||
@@ -64,7 +65,7 @@
|
||||
|
||||
try {
|
||||
if ($ImportColumns) {
|
||||
$end = $Worksheet.Dimension.End.Column
|
||||
$end = $sheet.Dimension.End.Column
|
||||
# Check $ImportColumns
|
||||
if ($ImportColumns[0] -le 0) { throw "The first entry in ImportColumns must be equal or greater 1" ; return }
|
||||
# Check $StartColumn and $EndColumn
|
||||
@@ -95,7 +96,7 @@
|
||||
|
||||
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
|
||||
$sheet.Cells[$StartRow, $C] | Where-Object { -not [string]::IsNullOrEmpty($_.Value) } | Select-Object @{N = 'Column'; E = { $C } }, Value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,15 +126,22 @@
|
||||
}
|
||||
try {
|
||||
#Select worksheet
|
||||
if (-not $WorksheetName) { $Worksheet = $ExcelPackage.Workbook.Worksheets[1] }
|
||||
if ($WorksheetName -eq '*') { $Worksheet = $ExcelPackage.Workbook.Worksheets }
|
||||
elseif (-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
|
||||
}
|
||||
|
||||
$xlBook = [Ordered]@{}
|
||||
foreach ($sheet in $Worksheet) {
|
||||
$EndRow = 0
|
||||
$EndColumn = 0
|
||||
$targetSheetname = $sheet.Name
|
||||
$xlBook["$targetSheetname"] = @()
|
||||
#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 }
|
||||
if (-not $EndRow ) { $EndRow = $sheet.Dimension.End.Row }
|
||||
if (-not $EndColumn) { $EndColumn = $sheet.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,
|
||||
@@ -145,7 +153,7 @@
|
||||
#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]) {
|
||||
foreach ($cell in $sheet.Cells[$range]) {
|
||||
if ($null -ne $cell.Value ) { $colHash[$cell.Start.Column] = 1; $rowHash[$cell.Start.row] = 1 }
|
||||
}
|
||||
$rows = ( $StartRow..$EndRow ).Where( { $rowHash[$_] })
|
||||
@@ -205,28 +213,43 @@
|
||||
foreach ($P in $PropertyNames) {
|
||||
$MatchTest = $TextColRegEx.Match($P.value)
|
||||
if ($MatchTest.groups.name -eq "astext") {
|
||||
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Text
|
||||
$NewRow[$P.Value] = $sheet.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))
|
||||
elseif ($MatchTest.groups.name -eq "asdate" -and $sheet.Cells[$R, $P.Column].Value -is [System.ValueType]) {
|
||||
$NewRow[$P.Value] = [datetime]::FromOADate(($sheet.Cells[$R, $P.Column].Value))
|
||||
}
|
||||
else { $NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value }
|
||||
else { $NewRow[$P.Value] = $sheet.Cells[$R, $P.Column].Value }
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($P in $PropertyNames) {
|
||||
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value
|
||||
$NewRow[$P.Value] = $sheet.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
|
||||
$xlBook["$targetSheetname"] += [PSCustomObject]$NewRow
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { throw "Failed importing the Excel workbook '$Path' with worksheet '$WorksheetName': $_"; return }
|
||||
finally {
|
||||
# $EndRow = 0
|
||||
# $EndColumn = 0
|
||||
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
|
||||
|
||||
if ($Raw) {
|
||||
foreach ($entry in $xlbook.GetEnumerator()) {
|
||||
$entry.Value
|
||||
}
|
||||
}
|
||||
elseif ($Worksheet.Count -eq 1) {
|
||||
$xlBook["$targetSheetname"]
|
||||
}
|
||||
else {
|
||||
$xlBook
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1248
README.original.md
Normal file
1248
README.original.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -63,6 +63,10 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
}
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Remove-Item $PSScriptRoot\testImportExcelSparse.xlsx -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
It "Import-Excel should have this shape" {
|
||||
$actual = @(Import-Excel $xlfile)
|
||||
|
||||
@@ -230,6 +234,7 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
|
||||
$actual.Count | Should -Be 1
|
||||
|
||||
Remove-Item $xlfile
|
||||
# Looks like -DataOnly does not handle empty columns
|
||||
# $actual[0].FirstName | Should -BeExactly 'Jean-Claude'
|
||||
# $actual[0].SecondName | Should -BeExactly 'Vandamme'
|
||||
|
||||
82
__tests__/ImportExcelTests/ImportExcelReadSheets.tests.ps1
Normal file
82
__tests__/ImportExcelTests/ImportExcelReadSheets.tests.ps1
Normal file
@@ -0,0 +1,82 @@
|
||||
#Requires -Modules Pester
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'False Positives')]
|
||||
param()
|
||||
|
||||
Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
|
||||
|
||||
Describe 'Different ways to import sheets' -Tag ImportExcelReadSheets {
|
||||
BeforeAll {
|
||||
$xlFilename = "$PSScriptRoot\yearlySales.xlsx"
|
||||
}
|
||||
|
||||
Context 'Test reading sheets' {
|
||||
It 'Should read one sheet' {
|
||||
$actual = Import-Excel $xlFilename
|
||||
|
||||
$actual.Count | Should -Be 100
|
||||
$actual[0].Month | Should -BeExactly "April"
|
||||
$actual[99].Month | Should -BeExactly "April"
|
||||
}
|
||||
|
||||
It 'Should read two sheets' {
|
||||
$actual = Import-Excel $xlFilename march, june
|
||||
|
||||
$actual.keys.Count | Should -Be 2
|
||||
$actual["March"].Count | Should -Be 100
|
||||
$actual["June"].Count | Should -Be 100
|
||||
}
|
||||
|
||||
It 'Should read all the sheets' {
|
||||
$actual = Import-Excel $xlFilename *
|
||||
|
||||
$actual.keys.Count | Should -Be 12
|
||||
|
||||
$actual["January"].Count | Should -Be 100
|
||||
$actual["February"].Count | Should -Be 100
|
||||
$actual["March"].Count | Should -Be 100
|
||||
$actual["April"].Count | Should -Be 100
|
||||
$actual["May"].Count | Should -Be 100
|
||||
$actual["June"].Count | Should -Be 100
|
||||
$actual["July"].Count | Should -Be 100
|
||||
$actual["August"].Count | Should -Be 100
|
||||
$actual["September"].Count | Should -Be 100
|
||||
$actual["October"].Count | Should -Be 100
|
||||
$actual["November"].Count | Should -Be 100
|
||||
$actual["December"].Count | Should -Be 100
|
||||
}
|
||||
|
||||
It 'Should throw if it cannot find the sheet' {
|
||||
{ Import-Excel $xlFilename april, june, notthere } | Should -Throw
|
||||
}
|
||||
|
||||
It 'Should return an array not a dictionary' {
|
||||
$actual = Import-Excel $xlFilename april, june -Raw
|
||||
|
||||
$actual.Count | Should -Be 200
|
||||
$group = $actual | Group-Object month -NoElement
|
||||
|
||||
$group.Count | Should -Be 2
|
||||
$group[0].Name | Should -BeExactly 'April'
|
||||
$group[1].Name | Should -BeExactly 'June'
|
||||
}
|
||||
|
||||
It "Should read multiple sheets with diff number of rows correctly" {
|
||||
$xlFilename = "$PSScriptRoot\construction.xlsx"
|
||||
|
||||
$actual = Import-Excel $xlFilename 2015, 2016
|
||||
$actual.keys.Count | Should -Be 2
|
||||
|
||||
$actual["2015"].Count | Should -Be 12
|
||||
$actual["2016"].Count | Should -Be 1
|
||||
}
|
||||
|
||||
It "Should read multiple sheets with diff number of rows correctly and flatten it" {
|
||||
$xlFilename = "$PSScriptRoot\construction.xlsx"
|
||||
|
||||
$actual = Import-Excel $xlFilename 2015, 2016 -Raw
|
||||
|
||||
$actual.Count | Should -Be 13
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
57
__tests__/ImportExcelTests/ReadMultipleXLSXFiles.tests.ps1
Normal file
57
__tests__/ImportExcelTests/ReadMultipleXLSXFiles.tests.ps1
Normal file
@@ -0,0 +1,57 @@
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'False Positives')]
|
||||
Param()
|
||||
|
||||
Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
|
||||
|
||||
Describe "Test reading multiple XLSX files of differernt row count" -Tag ReadMultipleXLSX {
|
||||
It "Should find these xlsx files" {
|
||||
Test-Path -Path $PSScriptRoot\rows05.xlsx | Should -BeTrue
|
||||
Test-Path -Path $PSScriptRoot\rows10.xlsx | Should -BeTrue
|
||||
}
|
||||
|
||||
It "Should find two xlsx files" {
|
||||
(Get-ChildItem $PSScriptRoot\row*xlsx).Count | Should -Be 2
|
||||
}
|
||||
|
||||
It "Should get 5 rows" {
|
||||
(Import-Excel $PSScriptRoot\rows05.xlsx).Count | Should -Be 5
|
||||
}
|
||||
|
||||
It "Should get 10 rows" {
|
||||
(Import-Excel $PSScriptRoot\rows10.xlsx).Count | Should -Be 10
|
||||
}
|
||||
|
||||
It "Should get 15 rows" {
|
||||
$actual = Get-ChildItem $PSScriptRoot\row*xlsx | Import-Excel
|
||||
|
||||
$actual.Count | Should -Be 15
|
||||
}
|
||||
|
||||
It "Should get 4 property names" {
|
||||
$actual = Get-ChildItem $PSScriptRoot\row*xlsx | Import-Excel
|
||||
|
||||
$names = $actual[0].psobject.properties.name
|
||||
$names.Count | Should -Be 4
|
||||
|
||||
$names[0] | Should -BeExactly "Region"
|
||||
$names[1] | Should -BeExactly "State"
|
||||
$names[2] | Should -BeExactly "Units"
|
||||
$names[3] | Should -BeExactly "Price"
|
||||
}
|
||||
|
||||
It "Should have the correct data" {
|
||||
$actual = Get-ChildItem $PSScriptRoot\row*xlsx | Import-Excel
|
||||
|
||||
# rows05.xlsx
|
||||
$actual[0].Region | Should -BeExactly "South"
|
||||
$actual[0].Price | Should -Be 181.52
|
||||
$actual[4].Region | Should -BeExactly "West"
|
||||
$actual[4].Price | Should -Be 216.56
|
||||
|
||||
# rows10.xlsx
|
||||
$actual[5].Region | Should -BeExactly "South"
|
||||
$actual[5].Price | Should -Be 199.85
|
||||
$actual[14].Region | Should -BeExactly "East"
|
||||
$actual[14].Price | Should -Be 965.25
|
||||
}
|
||||
}
|
||||
BIN
__tests__/ImportExcelTests/construction.xlsx
Normal file
BIN
__tests__/ImportExcelTests/construction.xlsx
Normal file
Binary file not shown.
BIN
__tests__/ImportExcelTests/rows05.xlsx
Normal file
BIN
__tests__/ImportExcelTests/rows05.xlsx
Normal file
Binary file not shown.
BIN
__tests__/ImportExcelTests/rows10.xlsx
Normal file
BIN
__tests__/ImportExcelTests/rows10.xlsx
Normal file
Binary file not shown.
BIN
__tests__/ImportExcelTests/yearlySales.xlsx
Normal file
BIN
__tests__/ImportExcelTests/yearlySales.xlsx
Normal file
Binary file not shown.
Binary file not shown.
20
changelog.md
20
changelog.md
@@ -1,3 +1,23 @@
|
||||
# v7.5.2
|
||||
- Changed the switch `-NotAsDictionary` to `-Raw`. Works with `-Worksheetname *` reads all the sheets in the xlsx file and returns an array.
|
||||
|
||||
# v7.5.1
|
||||
- Fixed `Import-Excel` - Reset `EndRow` and `EndColumn` in the correct place.
|
||||
# v7.5.0
|
||||
## Fixes
|
||||
|
||||
- Importing multiple files with Import-Excel by pipeline uses only the first file for the row count https://github.com/dfinke/ImportExcel/issues/1172
|
||||
|
||||
## New Features
|
||||
|
||||
- Import-Excel now supports importing multiple sheets. It can either return a dictionary of all sheets, or as a single array of all sheets combined.
|
||||
- `Import-Excel $xlfile *` # reads all sheets, returns all data in a dictionary
|
||||
- `Import-Excel $xlfile * -NotAsDictionary` # reads all sheets, returns all data in a single array
|
||||
- Added helper functions. Useful for working with an Excel package via `Open-ExcelPackage` or `-PassThru`
|
||||
- `Enable-ExcelAutoFilter`
|
||||
- `Enable-ExcelAutofit`
|
||||
- `Get-ExcelSheetDimensionAddress`
|
||||
|
||||
# v7.4.2
|
||||
|
||||
- Thank you [James Mueller](https://github.com/jamesmmueller) Updated `ConvertFrom-ExcelToSQLInsert` to handle single quotes in the SQL statement.
|
||||
|
||||
BIN
images/SalesData.png
Normal file
BIN
images/SalesData.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
images/SalesDataChart.png
Normal file
BIN
images/SalesDataChart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
BIN
images/SalesDataChartPivotTable.png
Normal file
BIN
images/SalesDataChartPivotTable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 238 KiB |
BIN
images/logo.png
Normal file
BIN
images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
images/logoWithInstall.png
Normal file
BIN
images/logoWithInstall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Reference in New Issue
Block a user