I am trying to set the protection for a worksheet so that the cells are not editable, but then allow editing of certain cells. This is to help the user when working with the exported excel file.
I guess this means protection at the cell level? I can't seem to figure it out...
I don't believe the version should matter. The ability to protect worksheets has been in the Excel assembly since it was introduced.
In what version of Excel are you opening the workbook?
Is it something to do with the version and I am using Infragistics2.Excel.v7.3?
I am not able to protect worksheet.
I ran the code you have posted and it works for me when I open the workbook in Excel 2007. You can also try making the workbook protected by setting wb.Protected to True.
I am trying like following snippet
Infragistics.Excel.
Workbook wb = new Infragistics.Excel.Workbook();
Infragistics.Excel.Worksheet sheet = wb.Worksheets.Add("ExpenseAllocation");
sheet.Protected =
true;
sheet.DisplayOptions.PanesAreFrozen =
false;
sheet.Rows[0].CellFormat.Font.Bold = Infragistics.Excel.ExcelDefaultableBoolean.True;
sheet.Rows[0].CellFormat.FillPattern = Infragistics.Excel.
FillPatternStyle.Solid;
sheet.Rows[0].CellFormat.FillPatternForegroundColor = System.Drawing.
Color.FromArgb(238, 243,255);
WorksheetRow headersRow = sheet.Rows[0];
headersRow.Cells[0].Value =
"Order ID";
headersRow.Cells[1].Value =
"Product";
headersRow.Cells[2].Value =
"Unit Price";
headersRow.Cells[3].Value =
"Quantity";
headersRow.Cells[4].Value =
"Discount";
headersRow.Cells[5].Value =
"Order Total";
I am not able to protect the worksheet. Can you please post the snippet.
Thanks,
Mani.