This project has moved. For the latest updates, please go here.

How can I lock worksheet?

Jan 28, 2011 at 12:21 PM


I have a trouble with EPPlus. I need to lock a worksheet. When I tried it this way


where password is a string variable, result was corrupted excel package, which can not be opened. Am I missing something? What is the "best practice" for locking worksheet.

I have got a czech version of Office, could it be the trouble?

Thank you in advance.


Jan 28, 2011 at 4:10 PM
Edited Jan 28, 2011 at 4:11 PM

No problem here in Brazilian and English versions of Office. I did the same way as you do.

Did you try without password ? works fine ?



Jan 30, 2011 at 5:31 PM

Can you provide a sample?

Jan 31, 2011 at 8:14 AM

Here is sample of my code:

using (ExcelPackage package = new ExcelPackage(template, true))

       ExcelWorksheet workSheet = package.Workbook.Worksheets.First();

       // filling workSheet with data


        return package.GetAsByteArray();


When I try to open the result I get the message like "Excel found unreadable content in
file..... do you want to recover it..." in czech of course...