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

[github-164] Fix Bug in XSSFTable.setCellReferences when table is single cell. #1283

Merged
merged 1 commit into from
Apr 16, 2024
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
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.
Loading