我可以使用Python + xlwings控制单元格的“自动换行”属性吗?
它目前尚未实现,但我已经打开了一个功能请求here。在此期间,您始终可以通过访问Windows上的基础COM对象来解决:Mac上的Range('A1').xl_range.WrapText = True
或appscript对象:Range('A1').xl_range.wrap_text.set(True)
。
对于最新的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