mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added new function 'Set-CellComment'
This commit is contained in:
@@ -88,6 +88,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
|
|||||||
'Remove-Worksheet',
|
'Remove-Worksheet',
|
||||||
'Select-Worksheet',
|
'Select-Worksheet',
|
||||||
'Send-SQLDataToExcel',
|
'Send-SQLDataToExcel',
|
||||||
|
'Set-CellComment',
|
||||||
'Set-CellStyle',
|
'Set-CellStyle',
|
||||||
'Set-ExcelColumn',
|
'Set-ExcelColumn',
|
||||||
'Set-ExcelRange',
|
'Set-ExcelRange',
|
||||||
|
|||||||
31
Public/Set-CellComment.ps1
Normal file
31
Public/Set-CellComment.ps1
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Scope='Function', Target='Set*', Justification='Does not change system state')]
|
||||||
|
param()
|
||||||
|
|
||||||
|
function Set-CellComment {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = "ColumnLetter")]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $True)]
|
||||||
|
[OfficeOpenXml.ExcelWorkSheet]$Worksheet,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $True)]
|
||||||
|
[Int]$Row,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $True, ParameterSetName = "ColumnLetter")]
|
||||||
|
[String]$ColumnLetter,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $True, ParameterSetName = "ColumnNumber")]
|
||||||
|
[Int]$ColumnNumber,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $True)]
|
||||||
|
[String]$Text
|
||||||
|
)
|
||||||
|
|
||||||
|
If ($PSCmdlet.ParameterSetName -eq "ColumnNumber") {
|
||||||
|
$ColumnLetter = (Get-ExcelColumnName -ColumnNumber $ColumnNumber).ColumnName
|
||||||
|
}
|
||||||
|
|
||||||
|
$a = "{0}{1}" -f $ColumnLetter,$Row
|
||||||
|
$t = $Worksheet.Cells[$a]
|
||||||
|
[Void]$t.AddComment($Text, "ImportExcel")
|
||||||
|
$t.Comment.AutoFit = $True
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user