Imports Infragistics.Documents.Excel
...
worksheet1.Protect(DirectCast(Nothing, System.Nullable(Of Boolean)))
worksheet1.Columns(1).CellFormat.Locked = ExcelDefaultableBoolean.False
You can disable editing of a worksheet by protecting it using the Worksheet object’s Protect method. This method has a lot of bool
arguments one of which is to disallow cell editing. When a worksheet is protected all subsequent calls to the Protect
method are ignored. To change the protections parameters you have to unprotect the worksheet using the Unprotect method and invoke the Protect
method again with the new protection settings set in its arguments. You can check if a worksheet is protected using the IsProtected property.
You can also use the Workbook object’s Protect method to protect a workbook against structural changes like adding, renaming, reordering and deleting of worksheets.
When protection is set, you can set the CellFormat object’s Locked property on individual cells, rows, merged cell regions, or columns to override the worksheet object’s protection on those objects. For example, if you need all cells of a worksheet to be read-only except for the cells of one column, you can protect the worksheet and then set the CellFormat property’s Locked property to False on a specific WorksheetColumn object. This will allow your end users to edit cells within the column while disabling editing of the other cells in the worksheet.
The following code shows you how to make one column editable while all other cells are read-only in a worksheet.
In Visual Basic:
Imports Infragistics.Documents.Excel
...
worksheet1.Protect(DirectCast(Nothing, System.Nullable(Of Boolean)))
worksheet1.Columns(1).CellFormat.Locked = ExcelDefaultableBoolean.False
In C#:
using Infragistics.Documents.Excel;
...
worksheet1.Protect((bool?)null);
worksheet1.Columns[1].CellFormat.Locked = ExcelDefaultableBoolean.False;