XlsxWriter는 내 오래된 직업을 1,000 배 쉽게 만들 수있는 훌륭한 모듈입니다 (John에게 감사합니다!). 그러나 셀을 포맷하면 시간이 오래 걸릴 수 있습니다. 이런 일을 할 때 사용하는 몇 가지 헬퍼 함수가 있습니다.
def box(workbook, sheet_name, row_start, col_start, row_stop, col_stop):
"""Makes an RxC box. Use integers, not the 'A1' format"""
rows = row_stop - row_start + 1
cols = col_stop - col_start + 1
for x in xrange((rows) * (cols)): # Total number of cells in the rectangle
box_form = workbook.add_format() # The format resets each loop
row = row_start + (x // cols)
column = col_start + (x % cols)
if x < (cols): # If it's on the top row
box_form = add_to_format(box_form, {'top':1}, workbook)
if x >= ((rows * cols) - cols): # If it's on the bottom row
box_form = add_to_format(box_form, {'bottom':1}, workbook)
if x % cols == 0: # If it's on the left column
box_form = add_to_format(box_form, {'left':1}, workbook)
if x % cols == (cols - 1): # If it's on the right column
box_form = add_to_format(box_form, {'right':1}, workbook)
sheet_name.write(row, column, "", box_form)
가에서 봐 주시기 바랍니다 :
지금과 그 기능의 해제 구축 :
먼저, 기존 형식에 속성을 추가하여 새로운 형식을 만들 수 있어야합니다 이 대답 http://stackoverflow.com/a/32964050/1731460 – pymen