I have spent hours troubleshooting this same problem. I have tried the following:
header_format = workbook.add_format({'bold': True, 'text_wrap': True, 'valign': 'top'})
And setting it through its own statement:
header_format.set_text_wrap()
And adding a boolean to the statement:
header_format.set_text_wrap(True)
I thought maybe it was because I was using conditional formatting:
worksheet.conditional_format(0, 0, 0, 21, {'type': 'no_blanks', 'format': header_format})
So I tried it without:
worksheet.set_row(0, 45, testing_format)
I thought that maybe because it was coming before the statement setting column widths below it that perhaps it needed to be at the very end (even though no other format settings exhibit this behavior). That didn't work.
I tried to use one formatting with only text_wrap set and no other formatting and used in no other places. That didn't work.
I tried it with it being the only formatting set for the entire worksheet. That didn't work
I tried updating XlsxWririter to 1.3.7. That didn't work.
At this point I can say with 100% confidence that text wrapping does not work in XlsxWriter 1.3.7 with Python 3.7.4, and Excel for Microsoft 365 MSO 64-bit.