Mat*_*Cox 8 python python-3.x openpyxl
在带有 openpyxl 的 Python 中,我想在用户打开电子表格时更改活动单元格。
这会产生“A1”:
print("Active Cell: " + WorkSheetOne.sheet_view.selection[0].activeCell)
Run Code Online (Sandbox Code Playgroud)
打开文件时会产生错误(文件损坏):
WorkSheetOne.sheet_view.selection[0].activeCell = 'A4'
Run Code Online (Sandbox Code Playgroud)
How can I set the active/selected cell to something other than A1?
对于 openpyxls 2.3.2 版本,我可以使用以下方法:
WorkSheetOne.sheet_view.selection[0].activeCell = 'A4'
WorkSheetOne.sheet_view.selection[0].sqref = 'A4'
Run Code Online (Sandbox Code Playgroud)
希望这对某人有帮助。