我这里有一段代码,它实际上可以使用pythonwin32com在excel中格式化边框。我关心的是制定边界的时间。我试图在excel中记录一个宏,以找出将其转换到脚本中所需的信息,但没有成功。在
所以我能做的最好的就是在for range循环中运行,我总是从第3行开始,到一个名为shn[1]的行计数器,增量为1,从第1列到第10列。从那里我使用“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)
我能做些什么来设置边框的格式,比如==>;工作表范围( 工作表单元格(3,1),工作表单元格(shn[1],10))?我尝试了“.Borders(11)”和“.Borders(12)”以及“.borderabout()”,但只有“.borderAbound()”起作用。在
提前谢谢。在
嗯,你在用什么excel?在
这应该是有效的:
告诉我这对你有什么用。在
如果将excel应用程序设置为“可见”或关闭屏幕更新,则速度可能更快:
^{pr2}$这样,excel就不会为每次呼叫更新屏幕。在
相关问题 更多 >
编程相关推荐