Hello all,
sorry for my (bad) english, it's not my native language. After a huge amount of time, I've decided to pick up programming again, in Lazarus.
I've created a spreadsheet with the FPSpreadsheet package and I am able to format all cells, set formula's and save it in xlsx-format.
After that, MS Excel is able to read my spreadsheet. So far so good. I am just not able to lock some cells from editting.
var cellprot : TsCellProtections;
cell : PCell;
begin
cell := MyWorksheet.FindCell(1,1); // "DATE" must be editable
// query cell protection
cellprot := Myworksheet.ReadCellProtection(cell);
// Unlock the cell for editing, don't change the visibility of formulas
Myworksheet.WriteCellProtection(cell, cellprot - [cpLockCell]);
// Hide formula of the cell and unlock the cell.
MyWorksheet.WriteCellProtection(cell, [cpHideFormulas]);
...
end;
It compiles without any errors/warnings. It runs and the xlsx has been created. But after opening it in MS Excel, I am still able to
edit cell(1,1), which is desired, but also all the other cells, which have been protected by:
MyWorksheet.Protection := [spCells, spDeleteColumns, spDeleteRows, spFormatCells, spFormatColumns, spFormatRows, spInsertColumns,
spInsertRows, spInsertHyperlinks, spSort];
Is there someone who can point me in the right direction?
Thanks in advance.
Martin