我有以下部分的PowerShell代码,它的工作原理完美,但我想知道是否有更简单的方法来做到这一点。更简单的方法来做到这一点?
我在Excel中采取不同的范围和格式有不同的线条样式和厚度的单元格边框,使它看起来一个管理报告
TIA 安迪
$formatCells = $ws1.Range("A1:W$a")
$formatCells.select()
$formatCells.font.size=10
$formatCells.Borders.Item($xledgebottom).Weight = $xlThick
$formatCells.Borders.Item($xledgetop).Weight = $xlThick
$formatCells.Borders.Item($xledgeleft).Weight = $xlThick
$formatCells.Borders.Item($xledgeright).Weight = $xlThick
$formatCells.Borders.Item($xledgebottom).LineStyle = $xlContinuous
$formatCells.Borders.Item($xledgetop).LineStyle = $xlContinuous
$formatCells.Borders.Item($xledgeright).LineStyle = $xlContinuous
$formatCells.Borders.Item($xledgeleft).LineStyle = $xlContinuous
$formatCells = $ws1.Range("A2:W2")
$formatCells.select()
$formatCells.Borders.Item($xledgebottom).Weight = $xlThin
$formatCells.Borders.Item($xledgebottom).LineStyle = $xlContinuous
$formatCells = $ws1.Range("A3:W$a")
$formatCells.select()
$formatCells.Borders.Item($xlinsidehorizontal).LineStyle = $xldot
$formatCells.Borders.Item($xlinsidevertical).LineStyle = $xldot
$formatCells.Borders.Item($xlinsidehorizontal).Weight = $xlhairline
$formatCells.Borders.Item($xlinsidevertical).weight = $xlhairline
$formatCells = $ws1.Range("C1:C$a")
$formatCells.select()
$formatCells.Borders.Item($xledgeright).Weight = $xlThick
$formatCells.Borders.Item($xledgeright).LineStyle = $xlContinuous
$formatCells = $ws1.Range("F1:F$a")
$formatCells.select()
$formatCells.Borders.Item($xledgeright).Weight = $xlThick
$formatCells.Borders.Item($xledgeright).LineStyle = $xlContinuous
$formatCells = $ws1.Range("J1:J$a")
$formatCells.select()
$formatCells.Borders.Item($xledgeright).Weight = $xlThick
$formatCells.Borders.Item($xledgeright).LineStyle = $xlContinuous
$formatCells.Borders.Item($xledgeleft).Weight = $xlThick
$formatCells.Borders.Item($xledgeleft).LineStyle = $xlContinuous
$formatCells = $ws1.Range("N1:N$a")
$formatCells.select()
$formatCells.Borders.Item($xledgeright).Weight = $xlThick
$formatCells.Borders.Item($xledgeright).LineStyle = $xlContinuous
$formatCells.Borders.Item($xledgeleft).Weight = $xlThick
$formatCells.Borders.Item($xledgeleft).LineStyle = $xlContinuous
$formatCells = $ws1.Range("R1:R$a")
$formatCells.select()
$formatCells.Borders.Item($xledgeright).Weight = $xlThick
$formatCells.Borders.Item($xledgeright).LineStyle = $xlContinuous
$formatCells.Borders.Item($xledgeleft).Weight = $xlThick
$formatCells.Borders.Item($xledgeleft).LineStyle = $xlContinuous
$formatCells = $ws1.Range("V1:V$a")
$formatCells.select()
$formatCells.Borders.Item($xledgeright).Weight = $xlThick
$formatCells.Borders.Item($xledgeright).LineStyle = $xlContinuous
$formatCells.Borders.Item($xledgeleft).Weight = $xlThick
$formatCells.Borders.Item($xledgeleft).LineStyle = $xlContinuous
哪里'bstyle'功能?你也应该在他们被调用之前声明你的函数。 – Matt
@Matt,我应该回答吗?如果你愿意,你可以修复代码 - 答案足够好。无论如何,这不应该是“让我做你的家庭作业”。 – majkinetor