Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python openpyxl cell width

from openpyxl.utils import get_column_letter

column_widths = []
for row in Workbook:
    for i, cell in enumerate(row):
        if len(column_widths) > i:
            if len(cell) > column_widths[i]:
                column_widths[i] = len(cell)
        else:
            column_widths += [len(cell)]

for i, column_width in enumerate(column_widths):
    worksheet.column_dimensions[get_column_letter(i+1)].width = column_width
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #openpyxl #cell #width
ADD COMMENT
Topic
Name
4+2 =