I'm working on a program and one of the needed features is to take a pandas dataframe and exports it to excel. This part works fine. When exporting, though, I need some of the cells to have their text rotated to be vertical rather than the default horizontal arrangement.
Here's what I have so far:
output = BytesIO()
writer = pd.ExcelWriter(output, engine='xlsxwriter')
filename = "Data for {} at {} on {}".format(item_no, loc, date)
columns = [('A:A', 18),
           ('B:B', 4),
           ('C:C', 18),
           ('D:Y', 20),
           ('Z:Z', 18),
           ('AA:AA', 12),
           ('AB:AB', 18),
           ('AC:AC', 12),
           ('AD:AD', 4),
           ('AE:AF', 18),
           ('AG:AG', 11),
           ('AH:AK', 16),
           ('AL:AL', 10),
           ('AM:AN', 14.5)]
df = fetch_data(item_no, loc, date)
df.to_excel(writer, index=False, sheet_name='Sheet1')
for col, width in columns:
    writer.sheets['Sheet1'].set_column(col, width)
writer.save()    
writer.close()
output.seek(0)
I know that the xlsxwriter library has format.set_rotation() but from what I can tell, this is only used when you use worksheet.write(..., format) rather than after pandas has written each cell to the sheet.
How would I go about getting certain of the cells to orient text vertically (90 degree rotation) rather than horizontally?  In particular, I'm interested in rotating the text in cells D1:Y1.
