# Needed help on protecting an excel workbook using python

**URL:** <https://discuss.python.org/t/needed-help-on-protecting-an-excel-workbook-using-python/5116>\
**Category:** Python Help\
**Created:** [September 1, 2020, 3:02pm UTC](https://discuss.python.org/t/needed-help-on-protecting-an-excel-workbook-using-python/5116 "2020-09-01T15:02:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanu1](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@Sanu1](https://discuss.python.org/u/Sanu1)\
**Post date:** [September 1, 2020, 3:02pm UTC](https://discuss.python.org/t/needed-help-on-protecting-an-excel-workbook-using-python/5116/1 "2020-09-01T15:02:23Z")

</div>

Hi ,  
I need some help on protecting excel workbook using python. I was using openpyxl library. But what I got is how to protect a sheet. But I need the whole workbook needed to be password protected.

I was using the below code for a sheet to be protected.

import openpyxl  
from openpyxl import Workbook  
book = Workbook()  
sheet = book.active  
sheet.protection.set\_password(‘test’)

This code only sets password on the sheet. But I need how to protect the whole excel workbook.  
Can anyone help?
