python设置excel边框_python win32com excel边框格式

嗯,你在用什么excel?在

这应该是有效的:for shn in [("Beam-Beam", bb_row, bb_col), ("Beam-Col", bc_row, bc_col)]:

sheet = book.Worksheets(shn[0])

sheet.Range( "J3:DW3" ).Copy()

if shn[0] == "Beam-Col":

sheet.Range( "J3:AA3" ).Copy()

## Set a variable named rng to the range

rng = sheet.Range( sheet.Cells( 4, 10 ), sheet.Cells( shn[1]-1, 10 ) )

rng.PasteSpecial()

## Using this range, we can now set its borders linestyle and weight

## -> where 7 through 13 correspond to borders for xlEdgeTop,xlEdgeBottom,

## xlEdgeRight, xlEdgeLeft, xlInsideHorizontal, and xlInsideVertical

## -> LineStyle of 1 = xlContinous

## -> Weight of 2 = xlThin

for border_id in xrange(7,13):

rng.Borders(border_id).LineStyle=1

rng.Borders(border_id).Weight=2

## And to finish just call

book.Close(True) # To close book and save

excel_app.Quit() # or some variable name established for the com instance

告诉我这对你有什么用。在

如果将excel应用程序设置为“可见”或关闭屏幕更新,则速度可能更快:

^{pr2}$

这样,excel就不会为每次呼叫更新屏幕。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值