Skip to content

This repository contains scripts to automate the removal of sheet protection tag from Excel .xlsx files for productivity purposes.

License

Notifications You must be signed in to change notification settings

jonas-lucas/unprotect-sheets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Unprotect Sheets

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.

How to Use

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.

How it Works

  1. Compress the sheet file .xlsx to .zip archive.
os.rename('file.xlsx', 'file.zip')
  1. Remove all <sheetProtection/> tags in all sheetn.xml files present in xl/worksheets folder 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.

  1. Restore the .zip file to a sheet file .xlsx.
os.rename('file.zip', 'file.xlsx')

Systems Settings

  • Windows 11 24H2
  • Python 3.13.3

Author

Jonas Lima

About

This repository contains scripts to automate the removal of sheet protection tag from Excel .xlsx files for productivity purposes.

Topics

Resources

License

Stars

Watchers

Forks

Languages