问题
Can I control the "Wrap Text" property of a cell using Python+xlwings?
回答1:
It's currently not implemented but I've opened a feature request here. In the meantime, you can always work around by accessing the underlying COM object on Windows: Range('A1').xl_range.WrapText = True
or appscript object on Mac: Range('A1').xl_range.wrap_text.set(True)
.
回答2:
For anybody like me who comes to this now and doesn't find these solutions are working, I found accessing the pywin32
API directly with work_sheet.range('A:A').api.WrapText = True
worked in Python 3.7 and xlwings 0.15.8 in Windows 7 and Excel 2010.
回答3:
For the newest xlwings version:
import xlwings as xw
wb1 = xw.Book('Book1.xlsm').sheets['Sheet1']
wb1.range('A1').value="It's currently not implemented but I've opened a feature request here. In the meantime, you can always work around by accessing the underlying COM object on Windows: "
wb1.range('A1').WrapText = True
来源:https://stackoverflow.com/questions/29258237/does-xlwings-support-wrap-text-property