Is there a way to format a table column using the column name ?
v-rusil opened this issue · comments
Rui Silva commented
As asked in Youtube, I'm working on a scenario where I'm importing server-side CSV information and formatting using you PS Module (Great stuff, BTW)
Here's what I'm trying to achieve:
$xlParams = @{
WorkSheet=$xls.Workbook.Worksheets[1]
Bold=$true
FontSize=18
AutoSize=$true
}
Set-Format -Range "A2" -Value "Report Process" @xlParams
would be great to be able to use something similar to:
Set-Format -Range $ws.Tables[0].Columns["ColumnName"] @xlParams
I checked on the code at https://github.com/dfinke/ImportExcel/blob/master/Public/Set-ExcelRange.ps1 (line 56 onwards) but it doesn't seem to accept a column:
#We should accept, a worksheet and a name of a range or a cell address; a table; the address of a table; a named range; a row, a column or .Cells[ ]
if ($Range -is [OfficeOpenXml.Table.ExcelTable]) {$Range = $Range.Address}
elseif ($Worksheet -and ($Range -is [string] -or $Range -is [OfficeOpenXml.ExcelAddress])) {
$Range = $Worksheet.Cells[$Range]
}
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.
Doug Finke commented
I believe the $Range
does not get that granular.