for (int r = 0; r < this.gridDesktop1.Worksheets[0].RowsCount; r++)
{
for (int c = 0; c < this.gridDesktop.Worksheets[0].ColumnsCount; c++)
{
Style s = this.gridDesktop.Worksheets[0].Cells[r, c].GetStyle();
s.CellLocked = true;
this.gridDesktop.Worksheets[0].Cells[r, c].SetStyle(s);
}
}
None of them seem to have the effect that I expected.
After initial testing, I am able to reproduce the issue as you mentioned. I could not make the Aspose.Cells.GridDesktop control read-only.
We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-56735
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@wknauf
Sorry for the inconvenience, the openAsReadOnly does not take effect.
We will fix it soon.
For the workaround, you need to do init work after the file is loaded,
Please try the below code:
private void button1_Click(object sender, EventArgs e)
{
this.gridDesktop1.ImportExcelFile(@"C:\Users\peter\Downloads\test.xlsx");
this.gridDesktop1.FinishLoadFile += gridDesktop1_Finish;
}
//you may do init work after the file is loaded
private void gridDesktop1_Finish(object sender, WorkBookEvents args)
{
for (int i = 0; i < this.gridDesktop1.Worksheets.Count; i++)
{
this.gridDesktop1.Worksheets[i].SetAllCellsReadonly();
}
}
Moreover, we are pleased to inform you your issue (Ticket ID: “CELLSNET-56735”) has been resolved now. The fix/enhancement will be incorporated in the next release (Aspose.Cells v24.10 package) scheduled for the first half of October 2024. You will receive a notification once the new release is available.
The issues you have found earlier (filed as CELLSNET-56735) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi
But an additional question: is it possible to disable the sheet bar context menu? Here, I can still delete the sheets though it was opened readonly. sheetbar_contextmenu.png (7.5 KB)
I see that I can hide the bar completely (this.gridDesktop1.SheetsBarVisible = false;), but we might show workbooks with multiple sheets. So it is required for us.
In Aspose.Cells for GridDesktop, there isn’t a direct property or method to completely disable the context menu for the sheet bar. This is same with MS Excel as default behavior. However, we can look into your desired option/requirements. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-56968
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.