Is there a way to prevent excel sheet cells from being selected and copied using openpyxl?

Viewed 93

I have protected my worksheet using the below code :-

import openpyxl
from openpyxl.styles import Protection,NamedStyle
work_book = openpyxl.load_workbook(r"xxxx") #Workbook 
work_sheet = work_book['Sheet1'] #worksheet of interest
work_sheet.protection.sheet = True #Protect the sheet
work_sheet.protection.password = 'xxxx' #Protection password

With the above code, I'm not able add anything in individual cells in the Excelsheet. However, I can be able to select all cells in the worksheet, copy them and paste contents in another sheet. In fact, this brings up the columns I've hidden etc. How can I prevent copying a protected worksheet contents via Openpyxl?

0 Answers
Related