This repository provides simple scripts to remove sheet protection tag from .xlsx (Excel) files. Useful for editing protected sheets or automating access to locked content.
Just run the command bellow:
python unprotect_sheet.py -i <xlsx_file>A new file will be generated in the format Unprotect<xlsx_file>, adding "Unprotect" at the beginning of the original file name.
- Compress the sheet file
.xlsxto.ziparchive.
os.rename('file.xlsx', 'file.zip')- Remove all
<sheetProtection/>tags in allsheetn.xmlfiles present inxl/worksheetsfolder on zipped file.
pattern = r'<sheetProtection\b[^<>]*?(?:/>|></sheetProtection>)'
cleaned_content = re.sub(pattern, '', original_content)The files are named
sheet1.xml,sheet2.xml, etc., each corresponding to a worksheet tab.
- Restore the
.zipfile to a sheet file.xlsx.
os.rename('file.zip', 'file.xlsx')- Windows 11 24H2
- Python 3.13.3