我有以下部分的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