Sep-02-2018, 07:00 AM
This merges the entire page exactly as I need:
Thanks for the through explanation on zip and col1/2. Zip seems like a handy function I need to know better.
Phil
start_col = [2, 4, 6, 8] end_col = [x + 1 for x in start_col] for i in range (1, 44): # this is row range # merges 9 cells into 1 in 1 row if i in [1, 4, 24, 41, 42, 43]: sheet.merge_cells(start_row=i, start_column=1, end_row=i, end_column=9) # merge 2 cells into 1 in 1 row elif i in [2, 3, 5, 8, 101, 11, 12, 13, 17, 18, 23, 25, 29, 30, 31, 32, 40]: sheet.merge_cells(start_row=i, start_column=2, end_row=i, end_column=3) sheet.merge_cells(start_row=i, start_column=4, end_row=i, end_column=5) sheet.merge_cells(start_row=i, start_column=6, end_row=i, end_column=7) sheet.merge_cells(start_row=i, start_column=8, end_row=i, end_column=9) # merge 2 cells into 1 and 4 cells into 1 cell, all in 1 row elif i in [22, 39]: sheet.merge_cells(start_row=i, start_column=2, end_row=i, end_column=3) sheet.merge_cells(start_row=i, start_column=6, end_row=i, end_column=9)Note the active cells in this sheet are rows 1-43 and columns A to I. I'm working on borders and alignment next.
Thanks for the through explanation on zip and col1/2. Zip seems like a handy function I need to know better.
Phil