Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking if cell is locked #1125

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenXmlFormats/Spreadsheet/Styles/CT_CellProtection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static CT_CellProtection Parse(XmlNode node, XmlNamespaceManager namespac
if (node == null)
return null;
CT_CellProtection ctObj = new CT_CellProtection();
ctObj.locked = XmlHelper.ReadBool(node.Attributes["locked"]);
ctObj.locked = XmlHelper.ReadBool(node.Attributes["locked"], true);
ctObj.hidden = XmlHelper.ReadBool(node.Attributes["hidden"]);
return ctObj;
}
Expand Down
1 change: 0 additions & 1 deletion ooxml/XSSF/UserModel/XSSFCellStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ public bool IsLocked
{
get
{

if (!_cellXf.IsSetProtection())
{
return true;
Expand Down
15 changes: 15 additions & 0 deletions testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,24 @@ public void TestGetSetLocked()
cellStyle.IsLocked = (false);
Assert.IsFalse(cellStyle.IsLocked);
}
[Test]
public void TestBug738()
{
XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("738.xlsx");

ISheet sheet = wb.GetSheet("Sheet1");
IRow row = sheet.GetRow(0);
ICell cell = row.GetCell(0);
Assert.IsTrue(cell.CellStyle.IsLocked);
cell.CellStyle.IsLocked = true;
Assert.IsTrue(cell.CellStyle.IsLocked);
Assert.IsTrue(cell.CellStyle.IsHidden);
}

[Test]
public void TestGetSetIndent()
{

Assert.AreEqual((short)0, cellStyle.Indention);
cellStyle.Indention = ((short)3);
Assert.AreEqual((short)3, cellStyle.Indention);
Expand Down
Binary file added testcases/test-data/spreadsheet/738.xlsx
Binary file not shown.