Does xlwings support “Wrap Text” property?

≯℡__Kan透↙ 提交于 2020-01-25 00:13:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!