xlwings支持"Wrap Text"财产吗?



我可以使用Python+xlwings控制单元格的"Wrap Text"属性吗?

它目前尚未实现,但我在这里打开了一个功能请求。同时,您可以通过访问Windows:mysheet.range('A1').api.WrapText = True上的底层COM对象或Mac:mysheet.range('A1').api.wrap_text.set(True)上的appscript对象来解决问题。

对于像我这样现在接触到这方面但没有发现这些解决方案有效的人,我发现在Windows 7和Excel 2010中,使用Python 3.7和xlwings 0.15.8中的work_sheet.range('A:A').api.WrapText = True直接访问pywin32 API。

对于最新的xlwings版本:

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

xlwings 0.19.5这项工作:

    sht.range('A1').api.WrapText = True

最新更新