I am trying to create an Excel workbook where I can auto-set, or auto-adjust the widths of the columns before saving the workbook.
I have been reading the Python-Ex
If one is not interested in using another class (FitSheetWrapper), then this can be implemented using WorkSheet column Method.
work = xlwt.WorkBook()
sheet = work.add_sheet('Sheet1')
for row_index in range(0,max_row):
for column_index in range(0,max_col) :
cwidth = sheet.col(column_index).width
if (len(column_data)*367) > cwidth:
sheet.col(column_index).width = (len(column_data)*367) #(Modify column width to match biggest data in that column)
sheet.write(row_index,column_index,column_data,style)
Default value of width is 2962 units and excel points it to as 8.11 units. Hence i am multiplying 367 to length of data.
This is adapted from Kevins FitSheetWrapper.