diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-03-15 09:40:48 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-03-15 09:40:48 +0000 |
commit | 935c8ab06a6dd7921b0d48067339aa9603b5a848 (patch) | |
tree | f18aa367ba05f1deee54935bada6ca64937c9cac /poi-ooxml | |
parent | f19233164c32a3af4ee8d0396adbda85290afc22 (diff) | |
download | poi-935c8ab06a6dd7921b0d48067339aa9603b5a848.tar.gz poi-935c8ab06a6dd7921b0d48067339aa9603b5a848.zip |
add xssf test (width/height)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898944 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 2 | ||||
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java | 30 |
2 files changed, 30 insertions, 2 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 8f13959b3b..513d9ad7ba 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -868,7 +868,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx * Get the actual column width (in units of 1/256th of a character width ) * * <p> - * Note, the returned value is always gerater that {@link #getDefaultColumnWidth()} because the latter does not include margins. + * Note, the returned value is always greater that {@link #getDefaultColumnWidth()} because the latter does not include margins. * Actual column width measured as the number of characters of the maximum digit width of the * numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. There are 4 pixels of margin * padding (two on each side), plus 1 pixel padding for the gridlines. diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 4dc4d622ef..385d0af869 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -18,6 +18,7 @@ package org.apache.poi.xssf.usermodel; import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.poi.xssf.XSSFTestDataSamples.openSamplePackage; import static org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook; import static org.apache.poi.xssf.XSSFTestDataSamples.writeOutAndReadBack; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -2190,7 +2191,7 @@ public final class TestXSSFSheet extends BaseTestXSheet { } @Test - public void bug65120() throws IOException { + void bug65120() throws IOException { try (XSSFWorkbook wb = new XSSFWorkbook()) { XSSFCreationHelper creationHelper = wb.getCreationHelper(); @@ -2222,4 +2223,31 @@ public final class TestXSSFSheet extends BaseTestXSheet { } } + @Test + void testCustomWidthAndHeight() throws IOException { + try (XSSFWorkbook wb = (XSSFWorkbook) _testDataProvider.openSampleWorkbook("WidthsAndHeights.xlsx")) { + XSSFSheet sheet = wb.getSheetAt(0); + assertEquals(5120, sheet.getColumnWidth(0)); + assertEquals(2048, sheet.getColumnWidth(1)); + assertEquals(0, sheet.getColumnWidth(2)); + assertEquals(140.034, sheet.getColumnWidthInPixels(0), 0.00001); + assertEquals(56.0136, sheet.getColumnWidthInPixels(1), 0.00001); + assertEquals(0.0, sheet.getColumnWidthInPixels(2), 0.00001); + assertFalse(sheet.isColumnHidden(0)); + assertFalse(sheet.isColumnHidden(1)); + assertTrue(sheet.isColumnHidden(2)); + XSSFRow row0 = sheet.getRow(0); + assertEquals(750, row0.getHeight()); + assertEquals(37.5, row0.getHeightInPoints(), 0.00001); + assertFalse(row0.getZeroHeight()); + XSSFRow row1 = sheet.getRow(1); + assertEquals(300, row1.getHeight()); + assertEquals(15.0, row1.getHeightInPoints(), 0.00001); + assertFalse(row1.getZeroHeight()); + XSSFRow row2 = sheet.getRow(2); + assertEquals(15, row2.getHeight()); + assertEquals(0.75, row2.getHeightInPoints(), 0.00001); + assertTrue(row2.getZeroHeight()); + } + } } |