필자는 필자가 필요로 할 때 정보를 추가하는 템플릿으로 사용하고있는 Excel 파일을 가지고 있습니다.범위에서 다른 범위로 스타일을 복사 하시겠습니까?
몇 가지 셀 범위에서 수행해야하는 특수한 스타일과 병합이 있습니다. 그러나 데이터가 많을 때 제가 지금하고있는 방식 (bruteforcing)은 매우 느립니다.
내가 더 잘할 수있는 방법이 있습니까? 여기
for a in xrange(1, len(plans)):
offset = 3 * a
# Create blank templates for plans
for x in xrange(5, 549):
first_col_cell = recommended.cell(row=x, column=4)
second_col_cell = recommended.cell(row=x, column=5)
third_col_cell = recommended.cell(row=x, column=6)
new_first_col_cell = recommended.cell(row=x, column=4 + offset)
new_second_col_cell = recommended.cell(row=x, column=5 + offset)
new_third_col_cell = recommended.cell(row=x, column=6 + offset)
if third_col_cell.has_style and x != 42:
new_third_col_cell.font = copy(third_col_cell.font)
new_third_col_cell.border = copy(third_col_cell.border)
new_third_col_cell.fill = copy(third_col_cell.fill)
new_third_col_cell.number_format = copy(third_col_cell.number_format)
new_third_col_cell.protection = copy(third_col_cell.protection)
new_third_col_cell.alignment = copy(third_col_cell.alignment)
new_third_col_cell.value = copy(third_col_cell.value)
if second_col_cell.has_style and x != 42:
new_second_col_cell.font = copy(second_col_cell.font)
new_second_col_cell.border = copy(second_col_cell.border)
new_second_col_cell.fill = copy(second_col_cell.fill)
new_second_col_cell.number_format = copy(second_col_cell.number_format)
new_second_col_cell.protection = copy(second_col_cell.protection)
new_second_col_cell.alignment = copy(second_col_cell.alignment)
new_second_col_cell.value = copy(second_col_cell.value)
if first_col_cell.has_style and x != 42:
new_first_col_cell.font = copy(first_col_cell.font)
new_first_col_cell.border = copy(first_col_cell.border)
new_first_col_cell.fill = copy(first_col_cell.fill)
new_first_col_cell.number_format = copy(first_col_cell.number_format)
new_first_col_cell.protection = copy(first_col_cell.protection)
new_first_col_cell.alignment = copy(first_col_cell.alignment)
new_first_col_cell.value = copy(first_col_cell.value)
if (x >= 6 and x <= 33) or x == 36 or x == 41 or x == 44:
recommended.merge_cells(start_row=x, start_column=4 + offset, end_row=x, end_column=6 + offset)
if first_col_cell.has_style:
recommended_merge = colnum_string(4 + offset) + str(x) + ':' + colnum_string(6 + offset) + str(x)
style_border(recommended, recommended_merge, border)
second_col_cell.border = copy(first_col_cell.border)
third_col_cell.border = copy(first_col_cell.border)
이 경우, 너무 calnum_string 기능의 필요한 것을 :
def colnum_string(n):
div=n
string=""
while div>0:
module=(div-1)%26
string=chr(65+module)+string
div=int((div-module)/26)
return string
100 계획 내 환경에 ~ 5 분을 필요로한다. 네 천천히? – stovfl
@stovfl, 아주 가깝습니다. 당황스럽게 천천히. 이 작업을 수행하는 더 좋은 방법을 찾아야합니다. – m0ngr31