I am trying to align text in a cell inside of an excel file that was created with xlwings. I am aware that there isn't a top level function in xlwings to achieve that. However, in the documentation, it states that .api can be used to access the pywin32 (on windows) to achieve that goal and in the documentation for pywin32 there is a method called SetTextAlign.
My problem is that I cannot figure out how to call it or what arguments to pass into it. A good bit of info can be found here: http://timgolden.me.uk/pywin32-docs/PyCDC__SetTextAlign_meth.html but that only helps me a tiny bit.
So, for example, my code could be:
self.sheet['A1'].value = 'test'
self.sheet['A1'].font.api ... # code here to set the alignment to center
Would be super appreciated if someone could help!
self.sheet['A1'].api.HorizontalAlignment = xlwings.constants.HAlign.xlHAlignCenter
Alignment is not a font property, but a Range property. A cell ('A1') is a Range.
You can find the Excel API here.
The PyCDC documentation you found is some internal Windows API, it is irrelevant for Excel features.