Powershell之Excel操作-网格线操作
1,定义网格线种类
$LineStyle = "microsoft.office.interop.excel.xlLineStyle" -as [type]
2,指定网格线种类
$sheet.cells.item(2,3).borders.LineStyle = $LineStyle::xlDashDotDot
网线种类:
        xlContinuous     实线
   xlDashDot      一点划线
   xlDashDotDot    二点划线
   xlDouble       双线
   xlSlantDashDot    斜线
   xlDash        虚线
   xlLineStyleNone   没有线
3,定义网线的宽度
$Weight = "microsoft.office.interop.excel.xlBorderWeight" -as [type]
4,指定网格线的宽度
$sheet.cells.item(2,3).borders.Weight = $Weight::xlMedium
网线宽度种类:
        xlHairline    及细
   xlThin        细
   xlMedium    中
   xlThick        粗
5,列宽自动调整
$range = $sheet.usedRange
$range.EntireColumn.AutoFit() | out-null
                    
                
                
            
        
浙公网安备 33010602011771号