mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
@@ -1339,6 +1339,14 @@ function Add-ExcelTable {
|
||||
[Switch]$PassThru
|
||||
)
|
||||
try {
|
||||
if ([OfficeOpenXml.FormulaParsing.ExcelUtilities.ExcelAddressUtil]::IsValidAddress($TableName)) {
|
||||
Write-Warning -Message "$tableName reads as an Excel address, and so is not allowed as a table name."
|
||||
return
|
||||
}
|
||||
if ($tableName -notMatch '^[A-Z]') {
|
||||
Write-Warning -Message "$tableName is not allowed as a table name because it does not begin with a letter."
|
||||
return
|
||||
}
|
||||
if ($TableName -match "\W") {
|
||||
Write-Warning -Message "At least one character in $TableName is illegal in a table name and will be replaced with '_' . "
|
||||
$TableName = $TableName -replace '\W', '_'
|
||||
|
||||
@@ -36,8 +36,8 @@ function New-ConditionalText {
|
||||
|
||||
This builds on the previous example, and specifies a condition of <=3 with
|
||||
a format of red text on a white background; this applies to a named range
|
||||
"Finish Position". The range could be written "C:C" to specify a named
|
||||
column, or "C2:C102" to specify certain cells in the column.
|
||||
"Finish Position". The range could be written -Range "C:C" to specify a
|
||||
named column, or -Range "C2:C102" to specify certain cells in the column.
|
||||
.Link
|
||||
Add-Add-ConditionalFormatting
|
||||
New-ConditionalFormattingIconSet
|
||||
|
||||
@@ -53,6 +53,9 @@ Install-Module ImportExcel -scope CurrentUser
|
||||
Install-Module ImportExcel
|
||||
```
|
||||
|
||||
# What's new
|
||||
- Set-ExcelRow and Set-ExcelColumn now check that the worksheet name they passed exists in the workbook.
|
||||
|
||||
# What's new 5.4
|
||||
|
||||
- Thank you to Conrad Agramont, Twitter: [@AGramont](https://twitter.com/@AGramont) for the `AddMultiWorkSheet.ps1` example. Much appreciated!
|
||||
|
||||
@@ -121,7 +121,12 @@
|
||||
|
||||
begin {
|
||||
#if we were passed a package object and a worksheet name , get the worksheet.
|
||||
if ($ExcelPackage) {$Worksheet = $ExcelPackage.Workbook.Worksheets[$Worksheetname] }
|
||||
if ($ExcelPackage) {
|
||||
if ($ExcelPackage.Workbook.Worksheets.Name -notcontains $Worksheetname) {
|
||||
throw "The Workbook does not contain a sheet named '$Worksheetname'"
|
||||
}
|
||||
else {$Worksheet = $ExcelPackage.Workbook.Worksheets[$Worksheetname] }
|
||||
}
|
||||
|
||||
#In a script block to build a formula, we may want any of corners or the column name,
|
||||
#if Column and Startrow aren't specified, assume first unused column, and first row
|
||||
|
||||
@@ -116,8 +116,12 @@
|
||||
)
|
||||
begin {
|
||||
#if we were passed a package object and a worksheet name , get the worksheet.
|
||||
if ($ExcelPackage) {$Worksheet = $ExcelPackage.Workbook.worksheets[$Worksheetname] }
|
||||
|
||||
if ($ExcelPackage) {
|
||||
if ($ExcelPackage.Workbook.Worksheets.Name -notcontains $Worksheetname) {
|
||||
throw "The Workbook does not contain a sheet named '$Worksheetname'"
|
||||
}
|
||||
else {$Worksheet = $ExcelPackage.Workbook.Worksheets[$Worksheetname] }
|
||||
}
|
||||
#In a script block to build a formula, we may want any of corners or the columnname,
|
||||
#if row and start column aren't specified assume first unused row, and first column
|
||||
if (-not $StartColumn) {$StartColumn = $Worksheet.Dimension.Start.Column }
|
||||
|
||||
Reference in New Issue
Block a user