I’ve been trying to unfreeze the first 2 rows and first column with openpyxl, however, when opening the file using Excel, I would get a message stating that Excel found some problem with some content in the file, and if I want to recover as much as they can. When I recover the contents of the file, it appears that the pane is not frozen anymore, even though that pop-up appeared.
Current code I have to unfreeze panes:
import openpyxl
from openpyxl.worksheet.views import Selection, Pane
filename = '...\ExcelFile.xlsx'
wb = openpyxl.loadworkbook(filename)
ws = wb.active
# current code to "unfreeze" panes
# get a pop-up error when opening file using excel
ws.views.sheetView[0].topLeftCell = 'A1' # scroll to top left corner
ws.views.sheetView[0].pane = Pane() # makes pane empty
ws.views.sheetView[0].selection[0] = Selection()
wb.save(filename)
Is there a way to not have the contents corrupted when unfreezing the panes? Would appreciate the help. Thanks.
Current data in Excel file (NOTE: working with only example data before applying to actual files):