mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-15 07:43:23 +00:00
Added support for Import-Excel -ASTEXT
This commit is contained in:
@@ -127,6 +127,9 @@ function Import-Excel {
|
|||||||
.PARAMETER EndColumn
|
.PARAMETER EndColumn
|
||||||
By default the import reads up to the last populated column, -EndColumn tells the import to stop at an earlier number.
|
By default the import reads up to the last populated column, -EndColumn tells the import to stop at an earlier number.
|
||||||
|
|
||||||
|
.PARAMETER AsText
|
||||||
|
Normally Import-Excel returns the Cell values. If AsText is specified the data is returned as the text displayed in the cells.
|
||||||
|
|
||||||
.PARAMETER Password
|
.PARAMETER 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.
|
||||||
|
|
||||||
@@ -314,6 +317,7 @@ function Import-Excel {
|
|||||||
[Alias('RightColumn')]
|
[Alias('RightColumn')]
|
||||||
[Int]$EndColumn ,
|
[Int]$EndColumn ,
|
||||||
[Switch]$DataOnly,
|
[Switch]$DataOnly,
|
||||||
|
[switch]$AsText,
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[String]$Password
|
[String]$Password
|
||||||
)
|
)
|
||||||
@@ -437,12 +441,17 @@ function Import-Excel {
|
|||||||
#Disabled write-verbose for speed
|
#Disabled write-verbose for speed
|
||||||
# Write-Verbose "Import row '$R'"
|
# Write-Verbose "Import row '$R'"
|
||||||
$NewRow = [Ordered]@{ }
|
$NewRow = [Ordered]@{ }
|
||||||
|
if ($AsText) {
|
||||||
foreach ($P in $PropertyNames) {
|
foreach ($P in $PropertyNames) {
|
||||||
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value
|
$NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Text
|
||||||
# Write-Verbose "Import cell '$($Worksheet.Cells[$R, $P.Column].Address)' with property name '$($p.Value)' and 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
|
[PSCustomObject]$NewRow
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user