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...
If the sheet is protected and you want to make some cells editable, you can set the cells' CellFormat.Locked properties to False.
I am not able to protect the worksheet. Can you please post the snippet.
Thanks,
Mani.
I am trying like following snippet Infragistics.Excel.
I am trying like following snippet
Infragistics.Excel.
Workbook wb = new Infragistics.Excel.Workbook();
Infragistics.Excel.Worksheet sheet = wb.Worksheets.Add("ExpenseAllocation"); sheet.Protected =
sheet.Protected =
true; sheet.DisplayOptions.PanesAreFrozen =
sheet.DisplayOptions.PanesAreFrozen =
false;
sheet.Rows[0].CellFormat.Font.Bold = Infragistics.Excel.ExcelDefaultableBoolean.True; sheet.Rows[0].CellFormat.FillPattern = Infragistics.Excel.
sheet.Rows[0].CellFormat.FillPattern = Infragistics.Excel.
FillPatternStyle.Solid; sheet.Rows[0].CellFormat.FillPatternForegroundColor = System.Drawing.
sheet.Rows[0].CellFormat.FillPatternForegroundColor = System.Drawing.
Color.FromArgb(238, 243,255); Infragistics.Excel.
WorksheetRow headersRow = sheet.Rows[0]; headersRow.Cells[0].Value =
headersRow.Cells[0].Value =
"Order ID"; headersRow.Cells[1].Value =
headersRow.Cells[1].Value =
"Product"; headersRow.Cells[2].Value =
headersRow.Cells[2].Value =
"Unit Price"; headersRow.Cells[3].Value =
headersRow.Cells[3].Value =
"Quantity"; headersRow.Cells[4].Value =
headersRow.Cells[4].Value =
"Discount"; headersRow.Cells[5].Value =
headersRow.Cells[5].Value =
"Order Total";
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.
Is it something to do with the version and I am using Infragistics2.Excel.v7.3?
I am not able to protect worksheet.