Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
Protect cells in Excel
posted

Hello,

I created an Excel file with the following code:

 Workbook exportWorkbook = new Workbook();

Worksheet exportWorksheet=exportWorkbook.Worksheets.Add("Export");

I filled some cells, and tried to protect the cells on the first row with the following code:

exportWorksheet.Rows[0].CellFormat.Locked = ExcelDefaultableBoolean.True;

exportWorksheet.Protected = true;

exportWorkbook.Protected = true;

exportWorkbook.Save(@"C:\Export\testexport.xls");

But when I open the file in Excel the cells are not protected. Did I miss some settings? Can anyone help me?

Thanks in advance.

Jennifer

  • 44743
    posted

    I tried your code and it worked for me. Try downloading the latest hotfix for the version you are using. It's possible a bug was fixed which addresses this issue. If you still have the problem with the latest hotfix, I would recommend submitting the issue to the support group: http://ko.infragistics.com/gethelp.