Skip to content

Commit

Permalink
Merge pull request #1283 from superrnovae/table_cellreferences
Browse files Browse the repository at this point in the history
[github-164] Fix Bug in XSSFTable.setCellReferences when table is single cell.
  • Loading branch information
tonyqus authored Apr 16, 2024
2 parents f0b0ea8 + 79dfd75 commit a8a827f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ooxml/XSSF/UserModel/XSSFTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,11 @@ public CellReference EndCellReference
*/
private void SetCellReferences()
{
String ref1 = ctTable.@ref;
string ref1 = ctTable.@ref;
if (ref1 != null) {
String[] boundaries = ref1.Split(new char[] { ':' }, 2);
String from = boundaries[0];
String to = boundaries[1];
string[] boundaries = ref1.Split(new char[] { ':' }, 2);
string from = boundaries[0];
string to = boundaries.Length == 2 ? boundaries[1] : boundaries[0];
startCellReference = new CellReference(from);
endCellReference = new CellReference(to);
}
Expand Down
9 changes: 9 additions & 0 deletions testcases/ooxml/XSSF/UserModel/TestXSSFTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,14 @@ public void FormatAsTable()
wb.Close();
}

[Test]
public void GetEndCellReferenceFromSingleCellTable()
{
XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("SingleCellTable.xlsx");
XSSFTable table = wb.GetTable("Table3");
Assert.AreEqual(new CellReference("A2"), table.EndCellReference);
wb.Close();
}

}
}
Binary file not shown.

0 comments on commit a8a827f

Please sign in to comment.