Range range= (Range)this.workSheet.Cells[1,1];
range.AllowEdit = false;
Quando ho creato la proprietà AllowEdit
false, un errore di compilazione mostrerà:Come rendere una cella excel ReadOnly usando C#?
Error: Property or indexer 'Microsoft.Office.Interop.Excel.Range.AllowEdit' cannot be assigned to -- it is read only
Come posso impostare l'intervallo di celle da sola lettura?
Quando sto usando la convalida per questa gamma Ho avuto qualche eccezione sul mio evento CellContentChanged.
Ecco il codice che si trova in CellContentChanged:
var updater = new Action<StyleColorItem>(
item =>
{
var editedItem = _taskViewModel.TrackedItems.First(it => it.Id == item.Id);
// Above line I am getting the exception like "Sequence contains no matching element"
editedItem.Update(item);'
});
cella A Excel può essere impostato per 'leggere only' solo di aver impostato è proprietà' Locked = true' e quindi impostare il 'WorkSheet = Protected'. Non so se è facile farlo con il codice C# ma potresti provarlo. – Schaliasos