Compare commits

..

60 Commits

Author SHA1 Message Date
dfinke
3a4c2d7bd9 bump version 2021-11-20 16:18:12 -05:00
dfinke
42cb5a316a update changelog 2021-11-20 16:18:05 -05:00
dfinke
536cdaa841 tweaked spelling 2021-11-20 15:53:23 -05:00
Doug Finke
6cd9fad7ba Merge pull request #1106 from royashbrook/CI-Updates
Add ACE into testing pipeline
2021-11-20 15:44:13 -05:00
Doug Finke
829d854c3d Merge pull request #1102 from muschebubusche/AddSelectiveColumnImport
Add selective column import
2021-11-20 15:36:05 -05:00
muschebubusche
b33a282740 Add new pester test 2021-11-20 16:51:49 +01:00
muschebubusche
73fc96166c Refactor selective column import
Move code into the function Get-PropertyNames and remove the rest.
Now it only replaces $Columns with $ImportColumns after a couple of checks. So the heavy work like arranging and getting the right values is done in the original way of Import-Excel.
2021-11-20 16:51:40 +01:00
Roy Ashbrook
00f7278115 add back *nix tests 2021-11-16 16:28:03 -05:00
Roy Ashbrook
956cf5aa49 fix 2021-11-16 16:23:54 -05:00
Roy Ashbrook
877310e015 add back pscore 2021-11-16 16:20:59 -05:00
Roy Ashbrook
08bf877535 add back in normal win testing 2021-11-16 16:11:32 -05:00
Roy Ashbrook
88e28a1d6c change path 2021-11-16 16:05:33 -05:00
Roy Ashbrook
eb63fe259a testing caching 2021-11-16 16:02:19 -05:00
Roy Ashbrook
6d97efc5c2 fun with curl... maybe 2021-11-16 15:43:57 -05:00
Roy Ashbrook
c567526eac testing caching 2021-11-16 15:34:36 -05:00
Roy Ashbrook
ed210cc730 testing 2021-11-16 15:29:32 -05:00
Roy Ashbrook
72f44ebcb9 trying a folder 2021-11-16 15:18:37 -05:00
Roy Ashbrook
f1d20ed163 test pipeline cache 2021-11-16 15:13:52 -05:00
Roy Ashbrook
02cf6bb3f3 test ace 2021-11-16 09:03:53 -05:00
dfinke
5cd3897dfa fix png 2021-11-12 19:26:57 -05:00
dfinke
fe4f2848ad bump version 2021-11-12 19:23:36 -05:00
dfinke
4e89b3321a update change log 2021-11-12 19:23:31 -05:00
Doug Finke
43b6ebf84f Merge pull request #1101 from royashbrook/Read-OleDbData
Add ability to query with Oledb
2021-11-12 18:59:41 -05:00
dfinke
1ee9493bc0 Minor tweak. Display query executed 2021-11-12 17:25:45 -05:00
muschebubusche
8f0fc7397d Add example and automatic column arrangement
Add example and automatic column arrangement
2021-11-09 22:40:40 +01:00
Roy Ashbrook
4fa6fbda01 update warning msg for Read-OleDbData 2021-11-09 09:05:15 -05:00
Roy Ashbrook
7177623104 add silent continue to cmd check tests 2021-11-08 18:21:11 -05:00
Roy Ashbrook
487cf51abc fix test skip label name 2021-11-08 18:19:23 -05:00
Roy Ashbrook
ae31e9d39b update skip/help msgs in invoke cmd 2021-11-08 18:08:45 -05:00
Roy Ashbrook
9ba20b8ec8 add back invoke tests, sync skip methods 2021-11-08 17:57:44 -05:00
Roy Ashbrook
9daefc2925 fix typo in skip logic 2021-11-08 17:45:33 -05:00
Roy Ashbrook
f0b4cb28f6 update tests to skip other pre-checks if linux/mac 2021-11-08 17:44:03 -05:00
Roy Ashbrook
5f00f5cbbc update tests 2021-11-08 17:40:33 -05:00
Roy Ashbrook
d41fbf8a05 updating tests 2021-11-08 17:13:40 -05:00
Roy Ashbrook
ebe49f1650 fix or/and 2021-11-08 16:56:23 -05:00
Roy Ashbrook
a3dced10e4 update tests 2021-11-08 16:37:00 -05:00
Roy Ashbrook
1e522c562b test skips for linux/macos, switch to warnings 2021-11-08 16:00:06 -05:00
Roy Ashbrook
5ec299ff2d some debugging messages for troubleshooting CI 2021-11-08 15:43:36 -05:00
Roy Ashbrook
676ecc17e0 update tests to match 2021-11-08 15:25:26 -05:00
Roy Ashbrook
aa1b0018ab Add examples 2021-11-08 15:14:46 -05:00
Roy Ashbrook
eabaab79c5 add ace check 2021-11-08 14:43:57 -05:00
Roy Ashbrook
7a8bbb9771 add to exported functions, formatting, fix typo. 2021-11-04 20:54:51 -04:00
Roy Ashbrook
85f2433ffc Rename helper function to make it more helpful. =) 2021-11-04 10:44:14 -04:00
muschebubusche
62c8d74a59 Add selective column import 2021-11-03 23:15:18 +01:00
Roy Ashbrook
5e7b404daf Add helper method 2021-11-03 10:35:22 -04:00
Roy Ashbrook
91a1240408 add skip test check for ace 2021-10-30 11:20:27 -04:00
Roy Ashbrook
e8c3d96f43 Tests relocated and updated. All passing. 2021-10-29 21:58:05 -04:00
Roy Ashbrook
9417b25af1 move tests into test folder 2021-10-29 16:58:16 -04:00
Roy Ashbrook
a942f2133d Add basic function, tests, and sample file 2021-10-29 13:21:52 -04:00
Doug Finke
533ed07ac8 Remove lowercase public
used for GitBook, no longer needed. #1082
2021-09-17 08:07:56 -04:00
Doug Finke
09f35b5fd5 Merge pull request #1078 from dfinke/Add-Checks-And-Warnings-for-Add-Member-Open-Excel-Package
Add-Checks-And-Warnings-for-Add-Member-Open-Excel-Package
2021-09-14 18:15:47 -04:00
dfinke
23a2ac394f Add try/catch, warning, and tests 2021-09-14 15:44:32 -04:00
dfinke
50928e8e3b Update 2021-09-14 15:44:11 -04:00
dfinke
26827b0764 bump version 2021-09-14 15:44:03 -04:00
Doug Finke
6c35d5b018 Updated 2021-09-10 18:41:03 -04:00
Doug Finke
ab5600c9ba bump version 2021-09-10 18:40:57 -04:00
Doug Finke
47dcc636d9 Merge pull request #1077 from stahler/Open-ExcelPackage
Update open-excelpackage.md
2021-09-10 18:39:00 -04:00
Stahler
1768c0ac92 Update open-excelpackage.md 2021-09-10 14:17:44 -04:00
Doug Finke
694fcdd8c1 Merge pull request #1059 from dfinke/add-test-for-ps-5-to-7-and-linux
Improved checks for Linux, Mac and PS 5.1 - #1056, #1057
2021-07-30 19:27:06 -04:00
dfinke
0192f4d822 Improved checks for Linux, Mac and PS 5.1 - #1056, #1057 2021-07-30 19:21:37 -04:00
44 changed files with 712 additions and 2000 deletions

View File

@@ -0,0 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
# Create example file
$xlFile = "$PSScriptRoot\ImportColumns.xlsx"
Get-Process | Export-Excel -Path $xlFile
# -ImportColumns will also arrange columns
Import-Excel -Path $xlFile -ImportColumns @(1,3,2) -NoHeader -StartRow 1
# Get only pm, npm, cpu, id, processname
Import-Excel -Path $xlFile -ImportColumns @(6,7,12,25,46) | Format-Table -AutoSize

View File

@@ -0,0 +1,14 @@
try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return }
$queries =
'select * from [sheet1$A:A]',
'select * from [sheet1$]',
'select * from [sheet1$A2:E11]',
'select F2,F5 from [sheet1$A2:E11]',
'select * from [sheet1$A2:E11] where F2 = "Grocery"',
'select F2 as [Category], F5 as [Discount], F5*2 as [DiscountPlus] from [sheet1$A2:E11]'
foreach ($query in $queries) {
"query: $($query)"
Invoke-ExcelQuery .\testOleDb.xlsx $query | Format-Table
}

Binary file not shown.

View File

@@ -6,7 +6,7 @@
RootModule = 'ImportExcel.psm1'
# Version number of this module.
ModuleVersion = '7.2.1'
ModuleVersion = '7.4.0'
# ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
@@ -64,6 +64,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
'Import-USPS',
'Invoke-AllTests',
'Invoke-Sum',
'Invoke-ExcelQuery',
'Join-Worksheet',
'LineChart',
'Merge-MultipleSheets',
@@ -80,6 +81,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
'Pivot',
'Read-Clipboard',
'ReadClipboardImpl',
'Read-OleDbData',
'Remove-Worksheet',
'Select-Worksheet',
'Send-SQLDataToExcel',

View File

@@ -35,7 +35,8 @@
[string[]]$AsText,
[string[]]$AsDate,
[ValidateNotNullOrEmpty()]
[String]$Password
[String]$Password,
[Int[]]$ImportColumns
)
end {
$sw = [System.Diagnostics.Stopwatch]::StartNew()
@@ -62,6 +63,16 @@
)
try {
if ($ImportColumns) {
$end = $Worksheet.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
if (($StartColumn -ne 1) -or ($EndColumn -ne $end)) { Write-Warning -Message "If ImportColumns is set, then individual StartColumn and EndColumn will be ignored." }
# Replace $Columns with $ImportColumns
$Columns = $ImportColumns
}
if ($HeaderName) {
$i = 0
foreach ($H in $HeaderName) {
@@ -84,7 +95,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
$Worksheet.Cells[$StartRow, $C] | Where-Object { -not [string]::IsNullOrEmpty($_.Value) } | Select-Object @{N = 'Column'; E = { $C } }, Value
}
}
}
@@ -185,7 +196,7 @@
}
$TextColRegEx = New-Object -TypeName regex -ArgumentList $TextColExpression , 9
}
else {$TextColRegEx = $null}
else { $TextColRegEx = $null }
foreach ($R in $rows) {
#Disabled write-verbose for speed
# Write-Verbose "Import row '$R'"
@@ -194,12 +205,12 @@
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] = $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))
$NewRow[$P.Value] = [datetime]::FromOADate(($Worksheet.Cells[$R, $P.Column].Value))
}
else { $NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value }
else { $NewRow[$P.Value] = $Worksheet.Cells[$R, $P.Column].Value }
}
}
else {

View File

@@ -0,0 +1,63 @@
#Requires -Version 5
function Invoke-ExcelQuery {
<#
.SYNOPSIS
Helper method for executing Read-OleDbData with some basic defaults.
For additional help, see documentation for Read-OleDbData cmdlet.
.DESCRIPTION
Uses Read-OleDbData to execute a sql statement against a xlsx file. For finer grained control over the interaction, you may use that cmdlet. This cmdlet assumes a file path will be passed in and the connection string will be built with no headers and treating all results as text.
Running this command is equivalent to running the following:
$FullName = (Get-ChildItem $Path).FullName
Read-OleDbData `
-ConnectionString "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$FullName;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'" `
-SqlStatement $Query
Note that this command uses the MICROSOFT.ACE.OLEDB provider and will not work without it.
If needed, please download the appropriate package from https://www.microsoft.com/en-us/download/details.aspx?id=54920.
.EXAMPLE
Invoke-ExcelQuery .\test.xlsx 'select ROUND(F1) as [A1] from [sheet3$A1:A1]'
.EXAMPLE
$Path = (Get-ChildItem 'test.xlsx').FullName
$Query = "select ROUND(F1) as [A] from [sheet1$A1:A1]"
Read-XlsxUsingOleDb -Path $Path -Query $Query
.EXAMPLE
$ReadDataArgs = @{
Path = .\test.xlsx
Query = Get-Content query.sql -Raw
}
$Results = Invoke-ExcelQuery @ReadDataArgs
#>
param(
#The path to the file to open.
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String] $Path, # var name consistent with Import-Excel
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String] $Query # var name consistent with Invoke-Sqlcmd
)
try {
if ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -notcontains "Microsoft.ACE.OLEDB.12.0") {
Write-Error "Microsoft.ACE.OLEDB.12.0 provider is missing! Please install from https://www.microsoft.com/en-us/download/details.aspx?id=54920"
return
}
}
catch {
Write-Error "System.Data.OleDb is not working or you are on an unsupported platform."
return
}
$FullName = (Get-ChildItem $Path).FullName
Read-OleDbData `
-ConnectionString "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$FullName;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'" `
-SqlStatement $Query
}

View File

@@ -1,10 +1,10 @@
function Open-ExcelPackage {
function Open-ExcelPackage {
[CmdLetBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword","")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")]
[OutputType([OfficeOpenXml.ExcelPackage])]
param(
#The path to the file to open.
[Parameter(Mandatory=$true)]$Path,
[Parameter(Mandatory = $true)]$Path,
#If specified, any running instances of Excel will be terminated before opening the file.
[switch]$KillExcel,
#The password for a protected worksheet, as a [normal] string (not a secure string).
@@ -13,7 +13,7 @@
[switch]$Create
)
if($KillExcel) {
if ($KillExcel) {
Get-Process -Name "excel" -ErrorAction Ignore | Stop-Process
while (Get-Process -Name "excel" -ErrorAction Ignore) {}
}
@@ -24,21 +24,26 @@
#Create the directory if required.
$targetPath = Split-Path -Parent -Path $Path
if (!(Test-Path -Path $targetPath)) {
Write-Debug "Base path $($targetPath) does not exist, creating"
$null = New-item -ItemType Directory -Path $targetPath -ErrorAction Ignore
Write-Debug "Base path $($targetPath) does not exist, creating"
$null = New-item -ItemType Directory -Path $targetPath -ErrorAction Ignore
}
New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $Path
}
elseif (Test-Path -Path $path) {
if ($Password) {$pkgobj = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $Path , $Password }
else {$pkgobj = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $Path }
if ($Password) { $pkgobj = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $Path , $Password }
else { $pkgobj = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $Path }
if ($pkgobj) {
foreach ($w in $pkgobj.Workbook.Worksheets) {
$sb = [scriptblock]::Create(('$this.workbook.Worksheets["{0}"]' -f $w.name))
Add-Member -InputObject $pkgobj -MemberType ScriptProperty -Name $w.name -Value $sb
try {
Add-Member -InputObject $pkgobj -MemberType ScriptProperty -Name $w.name -Value $sb -ErrorAction Stop
}
catch {
Write-Warning "Could not add sheet $($w.name) as 'short cut', you need to access it via `$wb.Worksheets['$($w.name)'] "
}
}
return $pkgobj
}
}
else {Write-Warning "Could not find $path" }
}
else { Write-Warning "Could not find $path" }
}

View File

@@ -1,3 +1,4 @@
#Requires -Version 5
function Read-Clipboard {
<#
.SYNOPSIS
@@ -22,30 +23,24 @@ function Read-Clipboard {
$Header
)
if ($IsWindows) {
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
if ($osInfo.ProductType -eq 1) {
$cvtParams = @{
Data = Get-Clipboard -Raw
}
if ($Delimiter) {
$cvtParams.Delimiter = $Delimiter
}
if ($Header) {
$cvtParams.Header = $Header
}
ReadClipboardImpl @cvtParams
}
else {
Write-Error "This command is only supported on the desktop."
}
if ($IsLinux -or $IsMacOS) {
Write-Error "Read-Clipboard only runs on Windows"
return
}
else {
Write-Error "This function is only available on Windows desktop"
$cvtParams = @{
Data = Get-Clipboard -Raw
}
if ($Delimiter) {
$cvtParams.Delimiter = $Delimiter
}
if ($Header) {
$cvtParams.Header = $Header
}
ReadClipboardImpl @cvtParams
}
function ReadClipboardImpl {

54
Public/Read-OleDbData.ps1 Normal file
View File

@@ -0,0 +1,54 @@
#Requires -Version 5
function Read-OleDbData {
<#
.SYNOPSIS
Read data from an OleDb source using dotnet classes. This allows for OleDb queries against excel spreadsheets. Examples will only be for querying xlsx files.
For additional documentation, see Microsoft's documentation on the System.Data OleDb namespace here:
https://docs.microsoft.com/en-us/dotnet/api/system.data.oledb
.DESCRIPTION
Read data from an OleDb source using dotnet classes. This allows for OleDb queries against excel spreadsheets. Examples will only be for querying xlsx files using ACE.
.EXAMPLE
Read-OleDbData `
-ConnectionString "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=file.xlsx;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'" `
-SqlStatement "select ROUND(F1) as [A] from [sheet1$A1:A1]"
.EXAMPLE
$ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=file.xlsx;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'"
$SqlStatement = "select ROUND(F1) as [A] from [sheet1$A1:A1]"
Read-OleDbData -ConnectionString $ConnectionString -SqlStatement $SqlStatement
.EXAMPLE
$ReadDataArgs = @{
SqlStatement = Get-Content query.sql -Raw
ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=file.xlsx;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'"
}
$Results = Read-OleDbData @ReadDataArgs
#>
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String] $ConnectionString,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String] $SqlStatement
)
try {
if ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -notcontains "Microsoft.ACE.OLEDB.12.0") {
Write-Warning "Microsoft.ACE.OLEDB.12.0 provider is missing! You will not be able to query Excel files without it. Please install from https://www.microsoft.com/en-us/download/details.aspx?id=54920"
}
}
catch {
Write-Error "System.Data.OleDb is not working or you are on an unsupported platform."
return
}
$DataTable = new-object System.Data.DataTable
$DataAdapter = new-object System.Data.OleDb.OleDbDataAdapter $SqlStatement, $ConnectionString
$null = $DataAdapter.Fill($DataTable)
$null = $DataAdapter.Dispose()
$DataTable.Rows | Select-Object $DataTable.Columns.ColumnName
}

View File

@@ -1,33 +1,66 @@
#Requires -Modules Pester
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
Describe "Import-Excel on a sheet with no headings" {
BeforeAll {
$xlfile = "TestDrive:\testImportExcel.xlsx"
$xlfileHeaderOnly = "TestDrive:\testImportExcelHeaderOnly.xlsx"
$xl = "" | Export-excel $xlfile -PassThru
$xlfile = "$PSScriptRoot\testImportExcel.xlsx"
$xlfileHeaderOnly = "$PSScriptRoot\testImportExcelHeaderOnly.xlsx"
$xlfileImportColumns = "$PSScriptRoot\testImportExcelImportColumns.xlsx"
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'
# Create $xlfile if it does not exist
if (!(Test-Path -Path $xlfile)) {
$xl = "" | Export-excel $xlfile -PassThru
Set-ExcelRange -Worksheet $xl.Sheet1 -Range A2 -Value 'D'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range B2 -Value 'E'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range C2 -Value 'F'
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'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range A2 -Value 'D'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range B2 -Value 'E'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range C2 -Value 'F'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range A3 -Value 'G'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range B3 -Value 'H'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range C3 -Value 'I'
Close-ExcelPackage $xl
}
Set-ExcelRange -Worksheet $xl.Sheet1 -Range A3 -Value 'G'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range B3 -Value 'H'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range C3 -Value 'I'
# Create $xlfileHeaderOnly if it does not exist
if (!(Test-Path -Path $xlfileHeaderOnly)) {
$xl = "" | Export-excel $xlfileHeaderOnly -PassThru
Close-ExcelPackage $xl
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'
# crate $xlfileHeaderOnly
$xl = "" | Export-excel $xlfileHeaderOnly -PassThru
Close-ExcelPackage $xl
}
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'
# Create $xlfileImportColumns if it does not exist
if (!(Test-Path -Path $xlfileImportColumns)) {
$xl = "" | Export-Excel $xlfileImportColumns -PassThru
Close-ExcelPackage $xl
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'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range D1 -Value 'D'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range E1 -Value 'E'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range F1 -Value 'F'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range A2 -Value '1'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range B2 -Value '2'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range C2 -Value '3'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range D2 -Value '4'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range E2 -Value '5'
Set-ExcelRange -Worksheet $xl.Sheet1 -Range F2 -Value '6'
Close-ExcelPackage $xl
}
}
It "Import-Excel should have this shape" {
@@ -167,7 +200,7 @@ Describe "Import-Excel on a sheet with no headings" {
}
It "Should" {
$xlfile = "TestDrive:\testImportExcelSparse.xlsx"
$xlfile = "$PSScriptRoot\testImportExcelSparse.xlsx"
$xl = "" | Export-excel $xlfile -PassThru
Set-ExcelRange -Worksheet $xl.Sheet1 -Range A1 -Value 'Chuck'
@@ -224,4 +257,139 @@ Describe "Import-Excel on a sheet with no headings" {
$actual[0].P2 | Should -Be 'B'
$actual[0].P3 | Should -Be 'C'
}
It "Should import correct data if -ImportColumns is used with the first column" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(1,2,4,5))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 4
$actualNames[0] | Should -Be 'A'
$actualNames[2] | Should -Be 'D'
$actual.Count | Should -Be 1
$actual[0].A | Should -Be 1
$actual[0].B | Should -Be 2
$actual[0].D | Should -Be 4
$actual[0].E | Should -Be 5
}
It "Should import correct data if -ImportColumns is used with the first column" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(1,3,4,5))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 4
$actualNames[0] | Should -Be 'A'
$actualNames[2] | Should -Be 'D'
$actual.Count | Should -Be 1
$actual[0].A | Should -Be 1
$actual[0].C | Should -Be 3
$actual[0].D | Should -Be 4
$actual[0].E | Should -Be 5
}
It "Should import correct data if -ImportColumns is used without the first column" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(2,3,6))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 3
$actualNames[0] | Should -Be 'B'
$actualNames[2] | Should -Be 'F'
$actual.Count | Should -Be 1
$actual[0].B | Should -Be 2
$actual[0].C | Should -Be 3
$actual[0].F | Should -Be 6
}
It "Should import correct data if -ImportColumns is used without the first column" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(2,5,6))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 3
$actualNames[0] | Should -Be 'B'
$actualNames[2] | Should -Be 'F'
$actual.Count | Should -Be 1
$actual[0].B | Should -Be 2
$actual[0].E | Should -Be 5
$actual[0].F | Should -Be 6
}
It "Should import correct data if -ImportColumns is used with only 1 column" {
$actual = @(Import-Excel $xlfile -ImportColumns @(2))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 1
$actualNames[0] | Should -Be 'B'
$actual.Count | Should -Be 2
$actual[0].B | Should -Be 'E'
}
It "Should import correct data if -ImportColumns is used with only 1 column which is also the last" {
$actual = @(Import-Excel $xlfile -ImportColumns @(3))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 1
$actualNames[0] | Should -Be 'C'
$actual.Count | Should -Be 2
$actual[1].C | Should -Be 'I'
}
It "Should import correct data if -ImportColumns contains all columns" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(1,2,3,4,5,6))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 6
$actualNames[0] | Should -Be 'A'
$actualNames[2] | Should -Be 'C'
$actual.Count | Should -Be 1
$actual[0].A | Should -Be 1
$actual[0].B | Should -Be 2
$actual[0].C | Should -Be 3
$actual[0].D | Should -Be 4
$actual[0].E | Should -Be 5
$actual[0].F | Should -Be 6
}
It "Should ignore -StartColumn and -EndColumn if -ImportColumns is set aswell" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(5) -StartColumn 2 -EndColumn 7)
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 1
$actualNames[0] | Should -Be 'E'
$actual[0].E | Should -Be '5'
}
It "Should arrange the columns if -ImportColumns is not in order" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(5,1,4))
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 3
$actualNames[0] | Should -Be 'E'
$actualNames[1] | Should -Be 'A'
$actualNames[2] | Should -Be 'D'
$actual[0].E | Should -Be '5'
$actual[0].A | Should -Be '1'
$actual[0].D | Should -Be '4'
}
It "Should arrange the columns if -ImportColumns is not in order and -NoHeader is used" {
$actual = @(Import-Excel $xlfileImportColumns -ImportColumns @(5,1,4) -NoHeader -StartRow 2)
$actualNames = $actual[0].psobject.properties.Name
$actualNames.Count | Should -Be 3
$actualNames[0] | Should -Be 'P1'
$actualNames[1] | Should -Be 'P2'
$actualNames[2] | Should -Be 'P3'
$actual[0].P1 | Should -Be '5'
$actual[0].P2 | Should -Be '1'
$actual[0].P3 | Should -Be '4'
}
}

View File

@@ -0,0 +1,39 @@
#Requires -Modules Pester
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
<#
Methods
-------
Dispose
Equals
GetAsByteArray
GetHashCode
GetType
Load
Save
SaveAs
ToString
Properties
----------
Compatibility
Compression
DoAdjustDrawings
Encryption
File
Package
Stream
Workbook
#>
Describe "Test Open Excel Package" -Tag Open-ExcelPackage {
It "Should handle opening a workbook with Worksheet Names that will cause errors" {
$xlFilename = "$PSScriptRoot\UnsupportedWorkSheetNames.xlsx"
{ Open-ExcelPackage -Path $xlFilename -ErrorAction Stop } | Should -Not -Throw
}
}

View File

@@ -0,0 +1,46 @@
#Requires -Modules Pester
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
$skip = $false
if ($IsLinux -or $IsMacOS) {
$skip = $true
Write-Warning "Invoke-ExcelQuery: Linux and MacOs are not supported. Skipping tests."
}else{
try {
if ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -notcontains "Microsoft.ACE.OLEDB.12.0") {
$skip = $true
Write-Warning "Invoke-ExcelQuery: Microsoft.ACE.OLEDB.12.0 provider not found. Skipping tests."
}
}
catch {
$skip = $true
Write-Warning "Invoke-ExcelQuery: Calls to System.Data.OleDb failed. Skipping tests."
}
}
Describe "Invoke-ExcelQuery" -Tag "Invoke-ExcelQuery" {
$PSDefaultParameterValues = @{ 'It:Skip' = $skip }
BeforeAll {
$tfp = "$PSScriptRoot\Read-OleDbData.xlsx"
}
Context "Basic Checks" {
It "Should have a valid Test file" {
Test-Path $tfp | Should -Be $true
}
It "Should have the Read-OleDbData command loaded" {
(Get-Command Read-OleDbData -ErrorAction SilentlyContinue) -ne $null | Should -Be $true
}
It "Should have the Invoke-ExcelQuery command loaded" {
(Get-Command Invoke-ExcelQuery -ErrorAction SilentlyContinue) -ne $null | Should -Be $true
}
}
Context "Sheet1`$A1" {
It "Should return 1 result with a value of 1" {
$Results = Invoke-ExcelQuery $tfp "select ROUND(F1) as [A1] from [sheet1`$A1:A1]"
@($Results).length + $Results.A1 | Should -Be 2
}
}
}

View File

@@ -0,0 +1,4 @@
select
ROUND(F1) as [A1]
from
[sheet3$A1:A1]

View File

@@ -0,0 +1,7 @@
select ROUND(F1) as [A1] from [sheet1$A1:A1]
union all select ROUND(F1) as [A1] from [sheet2$A1:A1]
union all select ROUND(F1) as [A1] from [sheet3$A1:A1]
union all select ROUND(F1) as [A1] from [sheet4$A1:A1]
union all select ROUND(F1) as [A1] from [sheet5$A1:A1]
union all select ROUND(F1) as [A1] from [sheet6$A1:A1]
union all select ROUND(F1) as [A1] from [sheet7$A1:A1]

View File

@@ -0,0 +1,4 @@
select
*
from
[sheet1$A1:E10]

View File

@@ -0,0 +1,10 @@
select top 1
'All A1s' as [A1],
F1 as [Sheet1],
(select F1 FROM [sheet2$a1:a1]) as [Sheet2],
(select F1 FROM [sheet3$a1:a1]) as [Sheet3],
(select F1 FROM [sheet4$a1:a1]) as [Sheet4],
(select F1 FROM [sheet5$a1:a1]) as [Sheet5],
(select F1 FROM [sheet6$a1:a1]) as [Sheet6],
(select F1 FROM [sheet7$a1:a1]) as [Sheet7]
FROM [sheet1$a1:a1]

View File

@@ -0,0 +1,31 @@
select top 1
'All A1s Start from Sheet1' as [A1],
F1 as [Sheet1],
(select F1 FROM [sheet2$a1:a1]) as [Sheet2],
(select F1 FROM [sheet3$a1:a1]) as [Sheet3],
(select F1 FROM [sheet4$a1:a1]) as [Sheet4]
FROM [sheet1$a1:a1]
UNION ALL
select top 1
'All A1s Start from Sheet2' as [A1],
(select F1 FROM [sheet1$a1:a1]) as [Sheet1],
F1 as [Sheet2],
(select F1 FROM [sheet3$a1:a1]) as [Sheet3],
(select F1 FROM [sheet4$a1:a1]) as [Sheet4]
FROM [sheet2$a1:a1]
UNION ALL
select top 1
'All A1s Start from Sheet3' as [A1],
(select F1 FROM [sheet1$a1:a1]) as [Sheet1],
(select F1 FROM [sheet2$a1:a1]) as [Sheet2],
F1 as [Sheet3],
(select F1 FROM [sheet4$a1:a1]) as [Sheet4]
FROM [sheet3$a1:a1]
UNION ALL
select top 1
'All A1s Start from Sheet4' as [A1],
(select F1 FROM [sheet1$a1:a1]) as [Sheet1],
(select F1 FROM [sheet2$a1:a1]) as [Sheet2],
(select F1 FROM [sheet3$a1:a1]) as [Sheet3],
F1 as [Sheet4]
FROM [sheet4$a1:a1]

View File

@@ -0,0 +1,92 @@
#Requires -Modules Pester
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
$skip = $false
if ($IsLinux -or $IsMacOS) {
$skip = $true
Write-Warning "Read-OleDbData: Linux and MacOs are not supported. Skipping tests."
}else{
try {
if ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -notcontains "Microsoft.ACE.OLEDB.12.0") {
$skip = $true
Write-Warning "Read-OleDbData: Microsoft.ACE.OLEDB.12.0 provider not found. Skipping tests."
}
}
catch {
$skip = $true
Write-Warning "Read-OleDbData: Calls to System.Data.OleDb failed. Skipping tests."
}
}
Describe "Read-OleDbData" -Tag "Read-OleDbData" {
$PSDefaultParameterValues = @{ 'It:Skip' = $skip }
BeforeAll {
$scriptPath = $PSScriptRoot
$tfp = "$scriptPath\Read-OleDbData.xlsx"
$cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$tfp;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'"
}
Context "Basic Tests" {
It "Should have a valid Test file" {
Test-Path $tfp | Should -Be $true
}
It "Should have the Read-OleDbData command loaded" {
(Get-Command Read-OleDbData -ErrorAction SilentlyContinue) -ne $null | Should -Be $true
}
It "Should be able to open spreadsheet" {
$null = Read-OleDbData -ConnectionString $cs -SqlStatement "select 1"
$true | Should -Be $true
}
It "Should return PSCustomObject for single result" {
#multiple records will come back as Object[], but not going to test for that
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement "select 1"
$Results.GetType().Name | Should -Be 'PSCustomObject'
}
}
Context "Sheet1`$A1" {
It "Should return 1 result with a value of 1" {
$sql = "select ROUND(F1) as [A1] from [sheet1`$A1:A1]"
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement $sql
@($Results).length + $Results.A1 | Should -Be 2
}
}
Context "Sheet2`$A1" {
It "Should return 1 result with value of 2" {
$sql = "select ROUND(F1) as [A1] from [sheet2`$A1:A1]"
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement $sql
@($Results).length + $Results.A1 | Should -Be 3
}
}
Context "Sheet3`$A1, Sql from file" {
It "Should return 1 result with value of 3" {
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestA.sql" -raw)
@($Results).length + $Results.A1 | Should -Be 4
}
}
Context "Sheets[1-7]`$A1, Sql from file" {
It "Should return 7 result with where sum values 1-6 = value 7" {
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestB.sql" -raw)
$a = $Results.A1
$a.length + ($a[0..5] | Measure-Object -sum).sum | Should -Be (7 + $a[6])
}
}
Context "Sheet1`$:A1:E10, Sql from file" {
#note, this spreadsheet doesn't have the fields populated other than A1, so it will, correctly, return only one value
It "Should return 1 result with value of 1" {
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestC.sql" -raw)
@($Results).length + $Results.F1 | Should -Be 2
}
}
Context "When Read-OleDbData.xlsx, select a1 from all sheets as a single record, and sql is in a file" {
It "should return one row with 8 columns" {
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestD.sql" -raw)
@($Results).length + @($Results.psobject.Properties).length | Should -Be 9
}
}
Context "When Read-OleDbData.xlsx, select a1 from all sheets as a single record multiple times to create a range, and sql is in a file" {
It "should return 4 records with 5 columns" {
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestE.sql" -raw)
@($Results).length + @($Results[0].psobject.Properties).length | Should -Be 9
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -20,6 +20,25 @@ jobs:
vmImage: 'windows-latest'
steps:
# BEGIN - ACE support for Invoke-ExcelQuery testing
- task: Cache@2
inputs:
key: v2 | "$(Agent.OS)" | ace
path: ace
cacheHitVar: CACHE_RESTORED
displayName: Cache ACE
- bash: |
mkdir ./ace
curl -o ./ace/ace.exe https://download.microsoft.com/download/3/5/C/35C84C36-661A-44E6-9324-8786B8DBE231/accessdatabaseengine_X64.exe
displayName: 'Download ACE'
condition: ne(variables.CACHE_RESTORED, 'true')
- powershell: Start-Process ./ace/ace.exe -Wait -ArgumentList "/quiet /passive /norestart"
displayName: 'Install ACE for Invoke-ExcelQuery testing'
# END - ACE support for Invoke-ExcelQuery testing
- powershell: 'Install-Module -Name Pester -Force -SkipPublisherCheck'
displayName: 'Update Pester'
- powershell: './CI/CI.ps1 -Test'
@@ -49,6 +68,25 @@ jobs:
vmImage: 'windows-latest'
steps:
# BEGIN - ACE support for Invoke-ExcelQuery testing
- task: Cache@2
inputs:
key: v2 | "$(Agent.OS)" | ace
path: ace
cacheHitVar: CACHE_RESTORED
displayName: Cache ACE
- bash: |
mkdir ./ace
curl -o ./ace/ace.exe https://download.microsoft.com/download/3/5/C/35C84C36-661A-44E6-9324-8786B8DBE231/accessdatabaseengine_X64.exe
displayName: 'Download ACE'
condition: ne(variables.CACHE_RESTORED, 'true')
- powershell: Start-Process ./ace/ace.exe -Wait -ArgumentList "/quiet /passive /norestart"
displayName: 'Install ACE for Invoke-ExcelQuery testing'
# END - ACE support for Invoke-ExcelQuery testing
- pwsh: 'Install-Module -Name Pester -Force'
displayName: 'Update Pester'
- pwsh: './CI/CI.ps1 -Test'

View File

@@ -1,7 +1,66 @@
# v7.4.0
- Thank you to [Max Goczall](https://github.com/muschebubusche) for this contribution!
- `ImportColumns` parameter added to `ImportExcel`. It is used to define which columns of the ExcelPackage should be imported.
```powershell
Import-Excel -Path $xlFile -ImportColumns @(6,7,12,25,46)
```
# v7.3.1
- Added query Excel spreadsheets, with SQL queries!
```powershell
$query = 'select F2 as [Category], F5 as [Discount], F5*2 as [DiscountPlus] from [sheet1$A2:E11]'
Invoke-ExcelQuery .\testOleDb.xlsx $query
```
![](./images/SQL-Spreadsheet.png)
## Result
```
Category Discount DiscountPlus
-------- -------- ------------
Cosmetics 0.7 1.4
Grocery 0.3 0.6
Apparels 0.2 0.4
Electronics 0.1 0.2
Electronics 0 0
Apparels 0.8 1.6
Electronics 0.7 1.4
Cosmetics 0.6 1.2
Grocery 0.4 0.8
Grocery 0.3 0.6
```
- Thank you to Roy Ashbrook for the SQL query code. Catch up with Roy:
|Media|Link|
|---|---|
|twitter|https://twitter.com/royashbrook
|github|https://github.com/royashbrook
|linkedin|https://linkedin.com/in/royashbrook
|blog|https://ashbrook.io
# v7.3.0
- Fix throwing error when a Worksheet name collides with a method, or property name on the `OfficeOpenXml.ExcelPackage` package
# v7.2.3
- Fix inline help, thank you [Wes Stahler](https://github.com/stahler)
# v7.2.2
- Improved checks for Linux, Mac and PS 5.1
# v7.2.1
- Improve auto-detection of data on the clipboard
# v7.2.0
- Added `Read-Clipboard` support for Windows. Read text from clipboard. It can read CSV or JSON. Plus, you can specify the delimiter and headers.

BIN
images/SQL-Spreadsheet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -9,7 +9,7 @@ schema: 2.0.0
## SYNOPSIS
Returns an ExcelPackage object for the specified XLSX fil.e
Returns an ExcelPackage object for the specified XLSX file.
## SYNTAX

View File

@@ -1,2 +0,0 @@
# Public

View File

@@ -1,157 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: null
schema: 2.0.0
---
# ConvertFrom-ExcelData
## SYNOPSIS
Reads data from a sheet, and for each row, calls a custom scriptblock with a list of property names and the row of data.
## SYNTAX
```text
ConvertFrom-ExcelData [-Path] <Object> [[-ScriptBlock] <ScriptBlock>] [[-WorksheetName] <Object>]
[[-HeaderRow] <Int32>] [[-Header] <String[]>] [-NoHeader] [-DataOnly] [<CommonParameters>]
```
## DESCRIPTION
## EXAMPLES
### EXAMPLE 1
```text
ConvertFrom-ExcelData .\testSQLGen.xlsx {
```
param\($propertyNames, $record\)
```text
$reportRecord = @()
foreach ($pn in $propertyNames) {
$reportRecord += "{0}: {1}" -f $pn, $record.$pn
}
$reportRecord +=""
$reportRecord -join "\`r\`n"
```
}
First: John Last: Doe The Zip: 12345 ....
## PARAMETERS
### -Path
```yaml
Type: Object
Parameter Sets: (All)
Aliases: FullName
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```
### -ScriptBlock
```yaml
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WorksheetName
```yaml
Type: Object
Parameter Sets: (All)
Aliases: Sheet
Required: False
Position: 3
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
```
### -HeaderRow
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
```
### -Header
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -NoHeader
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -DataOnly
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
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

@@ -1,71 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: null
schema: 2.0.0
---
# ConvertTo-ExcelXlsx
## SYNOPSIS
Converts an Excel xls to a xlsx using -ComObject
## SYNTAX
```text
ConvertTo-ExcelXlsx [-Path] <String> [-Force] [<CommonParameters>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -Path
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Force
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
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

@@ -1,59 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Get-ExcelColumnName
## SYNOPSIS
## SYNTAX
```text
Get-ExcelColumnName [[-ColumnNumber] <Object>] [<CommonParameters>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -ColumnNumber
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
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
### System.Object
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,116 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Get-HtmlTable
## SYNOPSIS
## SYNTAX
```text
Get-HtmlTable [-Url] <Object> [[-TableIndex] <Object>] [[-Header] <Object>] [[-FirstDataRow] <Int32>]
[-UseDefaultCredentials] [<CommonParameters>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -FirstDataRow
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Header
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UseDefaultCredentials
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -TableIndex
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Url
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,83 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Get-Range
## SYNOPSIS
## SYNTAX
```text
Get-Range [[-Start] <Object>] [[-Stop] <Object>] [[-Step] <Object>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -start
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Step
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -stop
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,55 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Get-XYRange
## SYNOPSIS
## SYNTAX
```text
Get-XYRange [[-TargetData] <Object>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -TargetData
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,116 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Import-Html
## SYNOPSIS
## SYNTAX
```text
Import-Html [[-Url] <Object>] [[-Index] <Object>] [[-Header] <Object>] [[-FirstDataRow] <Int32>]
[-UseDefaultCredentials] [<CommonParameters>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -FirstDataRow
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Header
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UseDefaultCredentials
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Index
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Url
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,69 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Import-UPS
## SYNOPSIS
## SYNTAX
```text
Import-UPS [[-TrackingNumber] <Object>] [-UseDefaultCredentials]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -TrackingNumber
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UseDefaultCredentials
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,69 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Import-USPS
## SYNOPSIS
## SYNTAX
```text
Import-USPS [[-TrackingNumber] <Object>] [-UseDefaultCredentials]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -TrackingNumber
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UseDefaultCredentials
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,83 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: 'https://github.com/dfinke/ImportExcel'
schema: 2.0.0
---
# Invoke-Sum
## SYNOPSIS
## SYNTAX
```text
Invoke-Sum [[-Data] <Object>] [[-Dimension] <Object>] [[-Measure] <Object>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -Data
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Dimension
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Measure
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,535 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: null
schema: 2.0.0
---
# New-ExcelStyle
## SYNOPSIS
## SYNTAX
```text
New-ExcelStyle [[-Range] <Object>] [[-NumberFormat] <Object>] [[-BorderAround] <ExcelBorderStyle>]
[[-BorderColor] <Object>] [[-BorderBottom] <ExcelBorderStyle>] [[-BorderTop] <ExcelBorderStyle>]
[[-BorderLeft] <ExcelBorderStyle>] [[-BorderRight] <ExcelBorderStyle>] [[-FontColor] <Object>]
[[-Value] <Object>] [[-Formula] <Object>] [-ArrayFormula] [-ResetFont] [-Bold] [-Italic] [-Underline]
[[-UnderLineType] <ExcelUnderLineType>] [-StrikeThru] [[-FontShift] <ExcelVerticalAlignmentFont>]
[[-FontName] <String>] [[-FontSize] <Single>] [[-BackgroundColor] <Object>]
[[-BackgroundPattern] <ExcelFillStyle>] [[-PatternColor] <Object>] [-WrapText]
[[-HorizontalAlignment] <ExcelHorizontalAlignment>] [[-VerticalAlignment] <ExcelVerticalAlignment>]
[[-TextRotation] <Int32>] [-AutoSize] [[-Width] <Single>] [[-Height] <Single>] [-Hidden] [-Locked] [-Merge]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -ArrayFormula
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AutoSize
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: AutoFit
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BackgroundColor
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 15
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BackgroundPattern
```yaml
Type: ExcelFillStyle
Parameter Sets: (All)
Aliases:
Accepted values: None, Solid, DarkGray, MediumGray, LightGray, Gray125, Gray0625, DarkVertical, DarkHorizontal, DarkDown, DarkUp, DarkGrid, DarkTrellis, LightVertical, LightHorizontal, LightDown, LightUp, LightGrid, LightTrellis
Required: False
Position: 16
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Bold
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BorderAround
```yaml
Type: ExcelBorderStyle
Parameter Sets: (All)
Aliases:
Accepted values: None, Hair, Dotted, DashDot, Thin, DashDotDot, Dashed, MediumDashDotDot, MediumDashed, MediumDashDot, Thick, Medium, Double
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BorderBottom
```yaml
Type: ExcelBorderStyle
Parameter Sets: (All)
Aliases:
Accepted values: None, Hair, Dotted, DashDot, Thin, DashDotDot, Dashed, MediumDashDotDot, MediumDashed, MediumDashDot, Thick, Medium, Double
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BorderColor
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BorderLeft
```yaml
Type: ExcelBorderStyle
Parameter Sets: (All)
Aliases:
Accepted values: None, Hair, Dotted, DashDot, Thin, DashDotDot, Dashed, MediumDashDotDot, MediumDashed, MediumDashDot, Thick, Medium, Double
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BorderRight
```yaml
Type: ExcelBorderStyle
Parameter Sets: (All)
Aliases:
Accepted values: None, Hair, Dotted, DashDot, Thin, DashDotDot, Dashed, MediumDashDotDot, MediumDashed, MediumDashDot, Thick, Medium, Double
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BorderTop
```yaml
Type: ExcelBorderStyle
Parameter Sets: (All)
Aliases:
Accepted values: None, Hair, Dotted, DashDot, Thin, DashDotDot, Dashed, MediumDashDotDot, MediumDashed, MediumDashDot, Thick, Medium, Double
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FontColor
```yaml
Type: Object
Parameter Sets: (All)
Aliases: ForegroundColor
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FontName
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 13
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FontShift
```yaml
Type: ExcelVerticalAlignmentFont
Parameter Sets: (All)
Aliases:
Accepted values: None, Baseline, Subscript, Superscript
Required: False
Position: 12
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FontSize
```yaml
Type: Single
Parameter Sets: (All)
Aliases:
Required: False
Position: 14
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Formula
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Height
```yaml
Type: Single
Parameter Sets: (All)
Aliases:
Required: False
Position: 22
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Hidden
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HorizontalAlignment
```yaml
Type: ExcelHorizontalAlignment
Parameter Sets: (All)
Aliases:
Accepted values: General, Left, Center, CenterContinuous, Right, Fill, Distributed, Justify
Required: False
Position: 18
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Italic
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Locked
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Merge
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -NumberFormat
```yaml
Type: Object
Parameter Sets: (All)
Aliases: NFormat
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -PatternColor
```yaml
Type: Object
Parameter Sets: (All)
Aliases: PatternColour
Required: False
Position: 17
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Range
```yaml
Type: Object
Parameter Sets: (All)
Aliases: Address
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResetFont
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -StrikeThru
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -TextRotation
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 20
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UnderLineType
```yaml
Type: ExcelUnderLineType
Parameter Sets: (All)
Aliases:
Accepted values: None, Single, Double, SingleAccounting, DoubleAccounting
Required: False
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Underline
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Value
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 9
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VerticalAlignment
```yaml
Type: ExcelVerticalAlignment
Parameter Sets: (All)
Aliases:
Accepted values: Top, Center, Bottom, Distributed, Justify
Required: False
Position: 19
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Width
```yaml
Type: Single
Parameter Sets: (All)
Aliases:
Required: False
Position: 21
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WrapText
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,41 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: null
schema: 2.0.0
---
# New-Plot
## SYNOPSIS
## SYNTAX
```text
New-Plot
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,41 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: null
schema: 2.0.0
---
# New-PSItem
## SYNOPSIS
## SYNTAX
```text
New-PSItem
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,113 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: null
schema: 2.0.0
---
# Set-CellStyle
## SYNOPSIS
## SYNTAX
```text
Set-CellStyle [[-Worksheet] <Object>] [[-Row] <Object>] [[-LastColumn] <Object>] [[-Pattern] <ExcelFillStyle>]
[[-Color] <Object>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -Color
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -LastColumn
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Pattern
```yaml
Type: ExcelFillStyle
Parameter Sets: (All)
Aliases:
Accepted values: None, Solid, DarkGray, MediumGray, LightGray, Gray125, Gray0625, DarkVertical, DarkHorizontal, DarkDown, DarkUp, DarkGrid, DarkTrellis, LightVertical, LightHorizontal, LightDown, LightUp, LightGrid, LightTrellis
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Row
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Worksheet
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS

View File

@@ -1,329 +0,0 @@
---
external help file: ImportExcel-help.xml
Module Name: ImportExcel
online version: null
schema: 2.0.0
---
# Set-WorksheetProtection
## SYNOPSIS
## SYNTAX
```text
Set-WorksheetProtection [-Worksheet] <ExcelWorksheet> [-IsProtected] [-AllowAll] [-BlockSelectLockedCells]
[-BlockSelectUnlockedCells] [-AllowFormatCells] [-AllowFormatColumns] [-AllowFormatRows] [-AllowInsertColumns]
[-AllowInsertRows] [-AllowInsertHyperlinks] [-AllowDeleteColumns] [-AllowDeleteRows] [-AllowSort]
[-AllowAutoFilter] [-AllowPivotTables] [-BlockEditObject] [-BlockEditScenarios] [[-LockAddress] <String>]
[[-UnLockAddress] <String>] [<CommonParameters>]
```
## DESCRIPTION
## EXAMPLES
### Example 1
```text
PS C:\> {{ Add example code here }}
```
## PARAMETERS
### -AllowAll
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowAutoFilter
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowDeleteColumns
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowDeleteRows
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowFormatCells
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowFormatColumns
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowFormatRows
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowInsertColumns
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowInsertHyperlinks
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowInsertRows
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowPivotTables
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowSort
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BlockEditObject
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BlockEditScenarios
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BlockSelectLockedCells
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BlockSelectUnlockedCells
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -IsProtected
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -LockAddress
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UnLockAddress
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Worksheet
```yaml
Type: ExcelWorksheet
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS