最近再練習寫用xlwings,但是遇到了問題,我在mac上嘗試修改字體大小,
fg1=sheet.range("A1:D1")
fg1.merge()
fg1.value="https://bbs.csdn.net/topics/消費賬單"
fg1.api.Font.Size=25
fg1.api.HorizontalAlignment=-4108
fg1.row_height=38.25
其中fg1.api.Font.Size=25這行報錯,報錯資訊是
Traceback (most recent call last):
File "/Users/mengchuancao/codeLibiary/workShopPy/untitled/venv/lib/python3.8/site-packages/aeosa/appscript/reference.py", line 599, in __getattr__
selectortype, code = self.AS_appdata.referencebyname()[name]
KeyError: 'Font'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/mengchuancao/codeLibiary/workShopPy/autoRecord/自動記賬.py", line 22, in <module>
sheetStyle()
File "/Users/mengchuancao/codeLibiary/workShopPy/autoRecord/自動記賬.py", line 18, in sheetStyle
fg1.api.Font.Size=25
File "/Users/mengchuancao/codeLibiary/workShopPy/untitled/venv/lib/python3.8/site-packages/aeosa/appscript/reference.py", line 601, in __getattr__
raise AttributeError("Unknown property, element or command: {!r}".format(name)) from e
AttributeError: Unknown property, element or command: 'Font'
但是在win下面這代碼運行就正常了,python是3.8,xlwings版本0.19,求助要怎么解決這個問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/36713.html
