Hi mamtachoudhary-6642,
You could not protect an Excel file with openxml.
Using password protection doesn't not generate an Office Open XML file and you will get a file in binary file format.
The Open XML SDK does not work with the binary file formats.
One suggestion is that you use Workbook.Password property to set the password:
Here are some similar threads you can refer to.
How to protect document with password using C# and openxml
Protecting Excel file created through OpenXML
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.