diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-07-01 13:14:52 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-07-01 13:14:52 +0000 |
commit | 86cc8d1b4b4e84470d45a67a4abb7a034612fd6a (patch) | |
tree | 533e0793bb771c8ccbd26638a674998c5b1baa6a /poi | |
parent | 2a040c42ec6de4e7f0a443cc039322c0cf7f36fd (diff) | |
download | poi-86cc8d1b4b4e84470d45a67a4abb7a034612fd6a.tar.gz poi-86cc8d1b4b4e84470d45a67a4abb7a034612fd6a.zip |
[bug-51037] apply default column style if no style set
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902391 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r-- | poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheet.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheet.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheet.java index 6c069f0539..bb70fa1c8f 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheet.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheet.java @@ -671,7 +671,45 @@ public abstract class BaseTestSheet { Cell cell = row.createCell(0); CellStyle style2 = cell.getCellStyle(); assertNotNull(style2); - assertEquals(style.getIndex(), style2.getIndex(), "style should match"); + assertEquals(style.getIndex(), style2.getIndex(), "style2 should match"); + + try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb)) { + Sheet wb2Sheet = wb2.getSheetAt(0); + assertNotNull(wb2Sheet.getColumnStyle(0)); + assertEquals(style.getIndex(), wb2Sheet.getColumnStyle(0).getIndex()); + + Row wb2R0 = wb2Sheet.getRow(0); + Cell wb2Cell = wb2R0.getCell(0); + CellStyle style3 = wb2Cell.getCellStyle(); + assertNotNull(style3); + assertEquals(style.getIndex(), style3.getIndex(), "style3 should match"); + } + + } + } + + @Test + protected void defaultRowStyle() throws IOException { + try (Workbook wb = _testDataProvider.createWorkbook()) { + CellStyle style = wb.createCellStyle(); + Sheet sheet = wb.createSheet(); + Row r0 = sheet.createRow(0); + r0.setRowStyle(style); + assertNotNull(r0.getRowStyle()); + assertEquals(style.getIndex(), r0.getRowStyle().getIndex()); + + Cell cell = r0.createCell(0); + CellStyle style2 = cell.getCellStyle(); + assertNotNull(style2); + //current implementations mean that cells inherit column style but not row style + assertNotEquals(style.getIndex(), style2.getIndex(), "style should not match"); + + try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb)) { + Sheet wb2Sheet = wb2.getSheetAt(0); + Row wb2R0 = wb2Sheet.getRow(0); + assertNotNull(wb2R0.getRowStyle()); + assertEquals(style.getIndex(), wb2R0.getRowStyle().getIndex()); + } } } |