Excel openpyxl-如何无法;冻结“U形窗格”;在.xlsx工作表中?
我在Windows上使用OpenPYXL3.0.5和python 3.7.9 我试图通过将“”设置为freeze_panes的值来禁用它,但它破坏了.xlsx文件,因此它不是答案Excel openpyxl-如何无法;冻结“U形窗格”;在.xlsx工作表中?,excel,openpyxl,Excel,Openpyxl,我在Windows上使用OpenPYXL3.0.5和python 3.7.9 我试图通过将“”设置为freeze_panes的值来禁用它,但它破坏了.xlsx文件,因此它不是答案 def x(target_book): sheet_data = target_book[sheet_name] sheet_data.freeze_panes = '' 请告诉我如何无法在.xlsx工作表中“冻结窗格”。当我们要解冻窗格时,需要以下代码 def x(target_book):
def x(target_book):
sheet_data = target_book[sheet_name]
sheet_data.freeze_panes = ''
请告诉我如何无法在.xlsx工作表中“冻结窗格”。当我们要解冻窗格时,需要以下代码
def x(target_book):
sheet_data = target_book[sheet_name]
sheet_data.freeze_panes = 'A1'
sheet_data.views.sheetView[0].selection[1] = ''
定义冻结窗格时,xml描述如下所示
-<sheetViews>
-<sheetView workbookViewId="0" zoomScaleNormal="85" zoomScale="85" topLeftCell="A65" showGridLines="0">
<pane topLeftCell="L1" state="frozen" activePane="topRight" xSplit="4"/>
<selection sqref="A42" activeCell="A42"/>
<selection sqref="B1:Q84" activeCell="B1" pane="topRight"/>
</sheetView>
</sheetViews>
我认为这种方式不明智,因此如果您有任何好的答案,请告诉我。您需要阅读OOXML规范中的工作表视图。谢谢您的建议,我找到了答案。
-<sheetViews>
-<sheetView zoomScaleNormal="85" zoomScale="85" workbookViewId="0" topLeftCell="A65" showGridLines="0">
<selection sqref="A42" activeCell="A42"/>
<selection sqref="B1:Q84" activeCell="B1" pane="topRight"/>
</sheetView>
</sheetViews>
sheet_data.views.sheetView[0].selection[1] = ''