Orient text in cell to vertical with XlsxWriter?
Asked Answered
S

1

7

I see a couple examples of how to set the orientation of a text box, but not cell in a text box. I see how to format other things, like bold:

bold_format = workbook.add_format({'bold': True})
worksheet.write('A1', "something", bold_format)

but not vertically oriented text.

Scandinavian answered 29/10, 2018 at 16:9 Comment(2)
You talking about this? xlsxwriter.readthedocs.io/format.html#set_rotationPolygamy
@Scratch'n'Purr: YesScandinavian
S
8

You can use set_rotation.

import xlsxwriter

workbook = xlsxwriter.Workbook("test.xlsx")
worksheet = workbook.add_worksheet()
worksheet.set_landscape()

bold_format = workbook.add_format({'bold': True})
bold_format.set_rotation(90)

worksheet.write('A1', "something", bold_format)

workbook.close()

For the entire documentation on set_rotation() visit: https://xlsxwriter.readthedocs.io/format.html#format-set-rotation

Supercolumnar answered 29/10, 2018 at 16:15 Comment(1)
You can also just put 'rotation': 90 in the format dictionaryCrownpiece

© 2022 - 2024 — McMap. All rights reserved.