CrHD
CrHD

Reputation: 43

Openpyxl: how change row height with write_only cells and workbook

I neeed to create xls file in write-only mode and customize rows height. But rows height stay by default if i use write_only=True.

row = []
book = Workbook(write_only=True)
sheet = book.create_sheet()
cell_1 = WriteOnlyCell(sheet)
# styling and filling cell data
row.append(cell_1)
cell_2 = WriteOnlyCell(sheet)
# styling and filling cell data
row.append(cell_2)
sheet.append(row)
sheet.row_dimensions[len(sheet.rows)].height = 30

Without write_only all works perfect.

Upvotes: 4

Views: 2276

Answers (2)

Chrismon Chin
Chrismon Chin

Reputation: 429

Must be done before any cells are added. See the warning section at the bottom of openpyxl.readthedocs.io/en/latest/optimized.html

Upvotes: 4

Charlie Clark
Charlie Clark

Reputation: 19507

Row and Column Dimensions are not available in write-only mode.

Upvotes: 0

Related Questions