1
我在这里有一段代码,实际上它使用python win32com在Excel中格式化边框。我关心的是格式化边界的时间。我试图在excel中记录一个宏,以找出所需的信息以将其转置到我的脚本中,但它不起作用。python win32com excel边框格式
所以我能做的最好的是运行在一个范围循环中,我总是从第3行开始,直到一个称为shn [1]的行计数器,增量为1,第1列为10,增量为1从那里我使用“BorderAround()”,它工作正常,但速度太慢。在这里我的一段代码:
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()
sheet.Range(sheet.Cells(4, 10), sheet.Cells(shn[1]-1, 10) ).PasteSpecial()
for mrow in xrange(3,shn[1],1):
for mcol in xrange(1,10,1):
sheet.Cells(mrow, mcol).BorderAround()#.Border(1)
有什么我可以做一个系列,如==> sheet.Range(sheet.Cells(3,1)设置边框的格式,sheet.Cells(SHN [1 ],10))?我尝试过“.Borders(11)”和“.Borders(12)”加上“.BorderAround()”,但只有“.BorderAround()”有效。
在此先感谢。