问题
I tried to look for it but couldn't find one. Is there a possibility to adjust the width,height of cells in excel in mm or cm dimensions using openpyxl or xlwt modules? if yes then can someone point me to the commands for scripting? thanks a lot.
回答1:
With Openpyxl
To set column width:
#setting width of column B to 12.25
sheet.column_dimensions['B'].width = float(12.25)
To set Row height:
#setting height of row 3 to 33.75
sheet.row_dimensions[3].height = float(33.75)
Hiding Columns and Rows
Using the dimensions we can also hide rows and columns:
#Hiding Column B
sheet.column_dimensions['B'].hidden = True
And with rows
#Hiding Row 3
sheet.row_dimensions[3].hidden = True
来源:https://stackoverflow.com/questions/43611920/adjusting-cells-width-and-height-in-excel-in-mm-cm-through-python-script