mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-12 14:23:14 +00:00
Compare commits
22 Commits
v7.8.1
...
Fix-Import
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebdfd3d090 | ||
|
|
a1986de292 | ||
|
|
30f2597f0d | ||
|
|
09c22654ab | ||
|
|
63f6543784 | ||
|
|
306e10c348 | ||
|
|
970febd6d3 | ||
|
|
e703a21dec | ||
|
|
c1be6a8d82 | ||
|
|
201b9cd984 | ||
|
|
559bfa2a7f | ||
|
|
4bd3efa1ef | ||
|
|
926042e5b6 | ||
|
|
be1e55cf8d | ||
|
|
a86c55b3ac | ||
|
|
fa14695fb9 | ||
|
|
6322bafaed | ||
|
|
c7a6f4ba35 | ||
|
|
49a6805727 | ||
|
|
c124ee199d | ||
|
|
858cf60a2f | ||
|
|
fcde64780e |
@@ -6,7 +6,7 @@
|
||||
RootModule = 'ImportExcel.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '7.8.1'
|
||||
ModuleVersion = '7.8.2'
|
||||
|
||||
# ID used to uniquely identify this module
|
||||
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
|
||||
|
||||
@@ -49,7 +49,7 @@ function Add-Worksheet {
|
||||
}
|
||||
else {$ExcelWorkbook.Worksheets.MoveBefore($WorksheetName, $MoveBefore)}
|
||||
}
|
||||
else {Write-Warning "Can't find worksheet '$MoveBefore'; worsheet '$WorksheetName' will not be moved."}
|
||||
else {Write-Warning "Can't find worksheet '$MoveBefore'; worksheet '$WorksheetName' will not be moved."}
|
||||
}
|
||||
elseif ($MoveAfter ) {
|
||||
if ($MoveAfter -eq "*") {
|
||||
@@ -68,7 +68,7 @@ function Add-Worksheet {
|
||||
$ExcelWorkbook.Worksheets.MoveAfter($WorksheetName, $MoveAfter)
|
||||
}
|
||||
}
|
||||
else {Write-Warning "Can't find worksheet '$MoveAfter'; worsheet '$WorksheetName' will not be moved."}
|
||||
else {Write-Warning "Can't find worksheet '$MoveAfter'; worksheet '$WorksheetName' will not be moved."}
|
||||
}
|
||||
#endregion
|
||||
if ($Activate) {Select-Worksheet -ExcelWorksheet $ws }
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
[Alias('Table')]
|
||||
$TableName,
|
||||
[OfficeOpenXml.Table.TableStyles]$TableStyle = [OfficeOpenXml.Table.TableStyles]::Medium6,
|
||||
[Switch]$Barchart,
|
||||
[Switch]$BarChart,
|
||||
[Switch]$PieChart,
|
||||
[Switch]$LineChart ,
|
||||
[Switch]$ColumnChart ,
|
||||
|
||||
@@ -16,6 +16,7 @@ function Get-ExcelFileSummary {
|
||||
[PSCustomObject][Ordered]@{
|
||||
ExcelFile = Split-Path -Leaf $Path
|
||||
WorksheetName = $workSheet.Name
|
||||
Visible = $workSheet.Hidden -eq 'Visible'
|
||||
Rows = $workSheet.Dimension.Rows
|
||||
Columns = $workSheet.Dimension.Columns
|
||||
Address = $workSheet.Dimension.Address
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
[Parameter(ParameterSetName = 'PackageC', Mandatory)]
|
||||
[Switch]$NoHeader ,
|
||||
[Alias('HeaderRow', 'TopRow')]
|
||||
[ValidateRange(1, 9999)]
|
||||
[ValidateRange(1, 1048576)]
|
||||
[Int]$StartRow = 1,
|
||||
[Alias('StopRow', 'BottomRow')]
|
||||
[Int]$EndRow ,
|
||||
@@ -235,7 +235,13 @@
|
||||
# Write-Verbose "Import cell '$($Worksheet.Cells[$R, $P.Column].Address)' with property name '$($p.Value)' and value '$($Worksheet.Cells[$R, $P.Column].Value)'."
|
||||
}
|
||||
}
|
||||
$xlBook["$targetSheetname"] += [PSCustomObject]$NewRow
|
||||
|
||||
if ($WorksheetName -eq '*') {
|
||||
$xlBook["$targetSheetname"] += [PSCustomObject]$NewRow
|
||||
}
|
||||
else {
|
||||
[PSCustomObject]$NewRow
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -247,16 +253,19 @@
|
||||
# $EndColumn = 0
|
||||
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
|
||||
|
||||
if ($Raw) {
|
||||
foreach ($entry in $xlbook.GetEnumerator()) {
|
||||
$entry.Value
|
||||
if ($WorksheetName -eq '*') {
|
||||
|
||||
if ($Raw) {
|
||||
foreach ($entry in $xlbook.GetEnumerator()) {
|
||||
$entry.Value
|
||||
}
|
||||
}
|
||||
elseif ($Worksheet.Count -eq 1) {
|
||||
$xlBook["$targetSheetname"]
|
||||
}
|
||||
else {
|
||||
$xlBook
|
||||
}
|
||||
}
|
||||
elseif ($Worksheet.Count -eq 1) {
|
||||
$xlBook["$targetSheetname"]
|
||||
}
|
||||
else {
|
||||
$xlBook
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
elseif ($Worksheet -and ($Range -is [string] -or $Range -is [OfficeOpenXml.ExcelAddress])) {
|
||||
$Range = $Worksheet.Cells[$Range]
|
||||
}
|
||||
elseif ($Range -is [string]) {Write-Warning -Message "The range pararameter you have specified also needs a worksheet parameter." ;return}
|
||||
elseif ($Range -is [string]) {Write-Warning -Message "The range parameter you have specified also needs a worksheet parameter." ;return}
|
||||
#else we assume $Range is a range.
|
||||
if ($ClearAll) {
|
||||
$Range.Clear()
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification = 'Only executes on versions without the automatic variable')]
|
||||
param()
|
||||
|
||||
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
|
||||
Import-Module $PSScriptRoot\..\ImportExcel.psd1
|
||||
}
|
||||
Import-Module $PSScriptRoot\..\ImportExcel.psd1 -Force
|
||||
|
||||
Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {
|
||||
Context "Test Get-ExcelFileSummary" {
|
||||
@@ -14,6 +12,7 @@ Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {
|
||||
|
||||
$actual.ExcelFile | Should -BeExactly 'TestData1.xlsx'
|
||||
$actual.WorksheetName | Should -BeExactly 'Sheet1'
|
||||
$actual.Visible | Should -BeTrue
|
||||
$actual.Rows | Should -Be 3
|
||||
$actual.Columns | Should -Be 2
|
||||
$actual.Address | Should -BeExactly 'A1:B3'
|
||||
@@ -26,6 +25,7 @@ Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {
|
||||
|
||||
$actual[0].ExcelFile | Should -BeExactly 'MultipleSheets.xlsx'
|
||||
$actual[0].WorksheetName | Should -BeExactly 'Sheet1'
|
||||
$actual[0].Visible | Should -BeTrue
|
||||
$actual[0].Rows | Should -Be 1
|
||||
$actual[0].Columns | Should -Be 4
|
||||
$actual[0].Address | Should -BeExactly 'A1:D1'
|
||||
@@ -33,11 +33,20 @@ Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {
|
||||
|
||||
$actual[1].ExcelFile | Should -BeExactly 'MultipleSheets.xlsx'
|
||||
$actual[1].WorksheetName | Should -BeExactly 'Sheet2'
|
||||
$actual[1].Visible | Should -BeTrue
|
||||
$actual[1].Rows | Should -Be 2
|
||||
$actual[1].Columns | Should -Be 2
|
||||
$actual[1].Address | Should -BeExactly 'A1:B2'
|
||||
$actual[1].Path | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Tests if sheet is hidden or not" {
|
||||
$actual = Get-ExcelFileSummary "$PSScriptRoot\ImportExcelTests\SheetVisibleTesting.xlsx"
|
||||
|
||||
$actual[0].Visible | Should -BeTrue
|
||||
$actual[1].Visible | Should -BeFalse
|
||||
$actual[2].Visible | Should -BeTrue
|
||||
$actual[3].Visible | Should -BeFalse
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ Describe 'Test' -Tag ImportExcelEndRowAndCols {
|
||||
$colNames[0] | Should -Be 'Units'
|
||||
$colNames[1] | Should -Be 'Price'
|
||||
}
|
||||
|
||||
It 'Should read any row up to maximum allowed row' {
|
||||
$xlMaxRows = "$PSScriptRoot\MaxRows.xlsx"
|
||||
$actual = Import-Excel $xlMaxRows -StartRow 1048576 -EndRow 1048576 -NoHeader
|
||||
$actual.P1 | Should -Be 1048576
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Test reading multiple sheets with data in differnt rows and columns' {
|
||||
|
||||
12
__tests__/ImportExcelTests/ImportExcelTiming.tests.ps1
Normal file
12
__tests__/ImportExcelTests/ImportExcelTiming.tests.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
|
||||
|
||||
Describe "Tests Import-Excel Timings" -Tag Timing {
|
||||
It "Should read the 20k xlsx in -le 2100 milliseconds" {
|
||||
$timer = Measure-Command {
|
||||
$data = Import-Excel $PSScriptRoot\TimingRows20k.xlsx
|
||||
}
|
||||
|
||||
$timer.TotalMilliseconds | Should -BeLessOrEqual 2100
|
||||
$data.Count | Should -Be 19999
|
||||
}
|
||||
}
|
||||
BIN
__tests__/ImportExcelTests/MaxRows.xlsx
Normal file
BIN
__tests__/ImportExcelTests/MaxRows.xlsx
Normal file
Binary file not shown.
BIN
__tests__/ImportExcelTests/SheetVisibleTesting.xlsx
Normal file
BIN
__tests__/ImportExcelTests/SheetVisibleTesting.xlsx
Normal file
Binary file not shown.
BIN
__tests__/ImportExcelTests/TimingRows20k.xlsx
Normal file
BIN
__tests__/ImportExcelTests/TimingRows20k.xlsx
Normal file
Binary file not shown.
@@ -1,3 +1,11 @@
|
||||
# 7.8.2
|
||||
|
||||
- Fix docs [#1254](https://github.com/dfinke/ImportExcel/pull/1251)`Add-Worksheet` warning. Thank you [Wilson Stewart](https://github.com/WilsonStewart)
|
||||
- Fix docs [#1251](https://github.com/dfinke/ImportExcel/pull/1251)`Add-Worksheet` warning. Thank you [Jeremiah Adams](https://github.com/JeremiahTheFirst)
|
||||
- Fix docs [#1253](https://github.com/dfinke/ImportExcel/pull/1253) `convertfrom-exceltosqlinsert`. Thank you [Wes Stahler](https://github.com/stahler)
|
||||
- Set Validate Range for rows to max rows available [#1273](https://github.com/dfinke/ImportExcel/pull/1273). Thank you [Stephen Brown](https://github.com/steve-daedilus)
|
||||
- Extended Get-ExcelFileSummary to include more Visible -eq $true|$false
|
||||
|
||||
# 7.8.1
|
||||
|
||||
- Fixed conditional formatting so it recognizes 'Top and Bottom' as a rule type. Thanks [g-pearl](https://github.com/g-pearl)
|
||||
|
||||
@@ -137,7 +137,7 @@ Accept wildcard characters: False
|
||||
|
||||
### -Header
|
||||
|
||||
Specifies custom property names to use, instead of the values defined in the column headers of the TopRow. If you provide fewr header names than there is data in the worksheet, then only the data with a corresponding header name will be imported and the data without header name will be disregarded. If you provide more header names than there is data in the worksheet, then all data will be imported and all objects will have all the property names you defined in the header names. As such, the last properties will be blank as there is no data for them.
|
||||
Specifies custom property names to use, instead of the values defined in the column headers of the TopRow. If you provide fewer header names than there is data in the worksheet, then only the data with a corresponding header name will be imported and the data without header name will be disregarded. If you provide more header names than there is data in the worksheet, then all data will be imported and all objects will have all the property names you defined in the header names. As such, the last properties will be blank as there is no data for them.
|
||||
|
||||
```yaml
|
||||
Type: String[]
|
||||
|
||||
Reference in New Issue
Block a user