diff --git a/src/java/org/apache/poi/hssf/record/NameRecord.java b/src/java/org/apache/poi/hssf/record/NameRecord.java index e4331c00f..9278ce607 100644 --- a/src/java/org/apache/poi/hssf/record/NameRecord.java +++ b/src/java/org/apache/poi/hssf/record/NameRecord.java @@ -536,7 +536,7 @@ public final class NameRecord extends ContinuableRecord { @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("[NAME]\n"); sb.append(" .option flags = ").append(HexDump.shortToHex(field_1_option_flag)).append("\n"); @@ -553,7 +553,7 @@ public final class NameRecord extends ContinuableRecord { Ptg[] ptgs = field_13_name_definition.getTokens(); sb.append(" .Formula (nTokens=").append(ptgs.length).append("):") .append("\n"); for (Ptg ptg : ptgs) { - sb.append(" " + ptg).append(ptg.getRVAType()).append("\n"); + sb.append(" ").append(ptg).append(ptg.getRVAType()).append("\n"); } sb.append(" .Menu text = ").append(field_14_custom_menu_text).append("\n"); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java index 39b1ab7da..1ce8a0ef5 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Locale; import org.apache.poi.POIXMLDocumentPart; -import org.apache.poi.POIXMLDocumentPart.RelationPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.Cell; @@ -80,8 +79,8 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { } /** - * @param part - * @throws IOException + * @param part The part used to initialize the table + * @throws IOException If reading data from the part fails. * @since POI 3.14-Beta1 */ public XSSFTable(PackagePart part) throws IOException { @@ -90,9 +89,9 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { } /** - * read table XML - * @param is - * @throws IOException + * Read table XML from an {@link InputStream} + * @param is The stream which provides the XML data for the table. + * @throws IOException If reading from the stream fails */ public void readFrom(InputStream is) throws IOException { try { @@ -111,9 +110,9 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { } /** - * write table XML to stream - * @param out - * @throws IOException + * write table XML to an {@link OutputStream} + * @param out The stream to write the XML data to + * @throws IOException If writing to the stream fails. */ public void writeTo(OutputStream out) throws IOException { updateHeaders(); @@ -265,7 +264,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * Changes the name of the Table - * @param newName + * @param newName The name of the table. */ public void setName(String newName) { if (newName == null) { @@ -290,7 +289,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * Changes the name of the Table - * @param newStyleName + * @param newStyleName The name of the style. * @since 3.17 beta 1 */ public void setStyleName(String newStyleName) { @@ -431,7 +430,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * The next call to {@link #getStartCellReference()} and * {@link #getEndCellReference()} will synchronize the * cell references with the underlying CTTable. - * Thus, {@link #updateReferences()} is inexpensive. + * Thus this method is inexpensive. * * @since POI 3.15 beta 3 */ @@ -466,7 +465,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * "Found unreadable content" message on startup. * * If calling both {@link #updateReferences()} and - * {@link #updateHeaders()}, {@link #updateReferences()} + * this method, {@link #updateReferences()} * should be called first. * * Note that a Table must have a header. To reproduce @@ -545,7 +544,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * Note: This is misleading. The Spec indicates this is true if the totals row * has ever been shown, not whether or not it is currently displayed. - * Use {@link #getTotalsRowCount()} > 0 to decide whether or not the totals row is visible. + * Use {@link #getTotalsRowCount()} > 0 to decide whether or not the totals row is visible. * @since 3.15 beta 2 * @see #getTotalsRowCount() */ @@ -555,7 +554,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @return 0 for no totals rows, 1 for totals row shown. - * Values > 1 are not currently used by Excel up through 2016, and the OOXML spec + * Values > 1 are not currently used by Excel up through 2016, and the OOXML spec * doesn't define how they would be implemented. * @since 3.17 beta 1 */ @@ -565,7 +564,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @return 0 for no header rows, 1 for table headers shown. - * Values > 1 might be used by Excel for pivot tables? + * Values > 1 might be used by Excel for pivot tables? * @since 3.17 beta 1 */ public int getHeaderRowCount() { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTextParagraph.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTextParagraph.java index e59fd706b..99d235901 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTextParagraph.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTextParagraph.java @@ -285,8 +285,8 @@ public class XSSFTextParagraph implements Iterable{ * Returns the bullet size that is to be used within a paragraph. * This may be specified in two different ways, percentage spacing and font point spacing: *

- * If bulletSize >= 0, then bulletSize is a percentage of the font size. - * If bulletSize < 0, then it specifies the size in points + * If bulletSize >= 0, then bulletSize is a percentage of the font size. + * If bulletSize < 0, then it specifies the size in points *

* * @return the bullet size @@ -313,8 +313,8 @@ public class XSSFTextParagraph implements Iterable{ * Sets the bullet size that is to be used within a paragraph. * This may be specified in two different ways, percentage spacing and font point spacing: *

- * If bulletSize >= 0, then bulletSize is a percentage of the font size. - * If bulletSize < 0, then it specifies the size in points + * If bulletSize >= 0, then bulletSize is a percentage of the font size. + * If bulletSize < 0, then it specifies the size in points *

*/ public void setBulletFontSize(double bulletSize){ @@ -497,8 +497,8 @@ public class XSSFTextParagraph implements Iterable{ * This element specifies the vertical line spacing that is to be used within a paragraph. * This may be specified in two different ways, percentage spacing and font point spacing: *

- * If linespacing >= 0, then linespacing is a percentage of normal line height - * If linespacing < 0, the absolute value of linespacing is the spacing in points + * If linespacing >= 0, then linespacing is a percentage of normal line height + * If linespacing < 0, the absolute value of linespacing is the spacing in points *

* Examples: *

@@ -526,8 +526,8 @@ public class XSSFTextParagraph implements Iterable{
      * Returns the vertical line spacing that is to be used within a paragraph.
      * This may be specified in two different ways, percentage spacing and font point spacing:
      * 

- * If linespacing >= 0, then linespacing is a percentage of normal line height. - * If linespacing < 0, the absolute value of linespacing is the spacing in points + * If linespacing >= 0, then linespacing is a percentage of normal line height. + * If linespacing < 0, the absolute value of linespacing is the spacing in points *

* * @return the vertical line spacing. @@ -564,8 +564,8 @@ public class XSSFTextParagraph implements Iterable{ * Set the amount of vertical white space that will be present before the paragraph. * This space is specified in either percentage or points: *

- * If spaceBefore >= 0, then space is a percentage of normal line height. - * If spaceBefore < 0, the absolute value of linespacing is the spacing in points + * If spaceBefore >= 0, then space is a percentage of normal line height. + * If spaceBefore < 0, the absolute value of linespacing is the spacing in points *

* Examples: *

@@ -591,8 +591,8 @@ public class XSSFTextParagraph implements Iterable{
      * The amount of vertical white space before the paragraph
      * This may be specified in two different ways, percentage spacing and font point spacing:
      * 

- * If spaceBefore >= 0, then space is a percentage of normal line height. - * If spaceBefore < 0, the absolute value of linespacing is the spacing in points + * If spaceBefore >= 0, then space is a percentage of normal line height. + * If spaceBefore < 0, the absolute value of linespacing is the spacing in points *

* * @return the vertical white space before the paragraph @@ -619,8 +619,8 @@ public class XSSFTextParagraph implements Iterable{ * Set the amount of vertical white space that will be present after the paragraph. * This space is specified in either percentage or points: *

- * If spaceAfter >= 0, then space is a percentage of normal line height. - * If spaceAfter < 0, the absolute value of linespacing is the spacing in points + * If spaceAfter >= 0, then space is a percentage of normal line height. + * If spaceAfter < 0, the absolute value of linespacing is the spacing in points *

* Examples: *

@@ -646,8 +646,8 @@ public class XSSFTextParagraph implements Iterable{
      * The amount of vertical white space after the paragraph
      * This may be specified in two different ways, percentage spacing and font point spacing:
      * 

- * If spaceBefore >= 0, then space is a percentage of normal line height. - * If spaceBefore < 0, the absolute value of linespacing is the spacing in points + * If spaceBefore >= 0, then space is a percentage of normal line height. + * If spaceBefore < 0, the absolute value of linespacing is the spacing in points *

* * @return the vertical white space after the paragraph @@ -715,11 +715,11 @@ public class XSSFTextParagraph implements Iterable{ if (props.isSetBuChar() || props.isSetBuAutoNum()) { setValue(true); return true; - } else { + } /*else { // Excel treats text with buFont but no char/autonum // as not bulleted // Possibly the font is just used if bullets turned on again? - } + }*/ } return false; } diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java index f4abd80b2..a0a1bc731 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java @@ -24,16 +24,17 @@ import org.apache.poi.POIDataSamples; import org.apache.poi.hsmf.exceptions.ChunkNotFoundException; import org.junit.Test; +import static org.junit.Assert.assertTrue; + /** * Tests to verify that we can read a simple msg file, that is in plain/text * format with no attachments or extra recipents. */ -public final class TestSimpleFileRead extends TestCase { +public final class TestSimpleFileRead { private final MAPIMessage mapiMessage; /** * Initialize this test, load up the blank.msg mapi message. - * @throws Exception */ public TestSimpleFileRead() throws IOException { POIDataSamples samples = POIDataSamples.getHSMFInstance(); @@ -42,9 +43,9 @@ public final class TestSimpleFileRead extends TestCase { /** * Test to see if we can read the CC Chunk. - * @throws ChunkNotFoundException * */ + @Test public void testReadDisplayCC() throws ChunkNotFoundException { String obtained = mapiMessage.getDisplayCC(); String expected = ""; @@ -54,9 +55,8 @@ public final class TestSimpleFileRead extends TestCase { /** * Test to see if we can read the CC Chunk. - * @throws ChunkNotFoundException - * */ + @Test public void testReadDisplayTo() throws ChunkNotFoundException { String obtained = mapiMessage.getDisplayTo(); String expected = "travis@overwrittenstack.com"; @@ -66,9 +66,8 @@ public final class TestSimpleFileRead extends TestCase { /** * Test to see if we can read the From Chunk. - * @throws ChunkNotFoundException - * */ + @Test public void testReadDisplayFrom() throws ChunkNotFoundException { String obtained = mapiMessage.getDisplayFrom(); String expected = "Travis Ferguson"; @@ -78,9 +77,8 @@ public final class TestSimpleFileRead extends TestCase { /** * Test to see if we can read the CC Chunk. - * @throws ChunkNotFoundException - * */ + @Test public void testReadDisplayBCC() throws ChunkNotFoundException { String obtained = mapiMessage.getDisplayBCC(); String expected = ""; @@ -91,9 +89,8 @@ public final class TestSimpleFileRead extends TestCase { /** * Check if we can read the body of the blank message, we expect "". - * - * @throws Exception */ + @Test public void testReadBody() throws Exception { String obtained = mapiMessage.getTextBody(); String expected = "This is a test message."; @@ -103,9 +100,8 @@ public final class TestSimpleFileRead extends TestCase { /** * Check if we can read the subject line of the blank message, we expect "" - * - * @throws Exception */ + @Test public void testReadSubject() throws Exception { String obtained = mapiMessage.getSubject(); String expected = "test message"; @@ -115,9 +111,8 @@ public final class TestSimpleFileRead extends TestCase { /** * Check if we can read the subject line of the blank message, we expect "" - * - * @throws Exception */ + @Test public void testReadConversationTopic() throws Exception { String obtained = mapiMessage.getConversationTopic(); TestCase.assertEquals("test message", obtained); @@ -126,9 +121,8 @@ public final class TestSimpleFileRead extends TestCase { /** * Check if we can read the subject line of the blank message, we expect "" - * - * @throws Exception */ + @Test public void testReadMessageClass() throws Exception { MAPIMessage.MESSAGE_CLASS obtained = mapiMessage.getMessageClassEnum(); TestCase.assertEquals(MAPIMessage.MESSAGE_CLASS.NOTE, obtained); @@ -136,8 +130,6 @@ public final class TestSimpleFileRead extends TestCase { /** * Check the various message classes - * - * @throws Exception */ @Test public void testReadMessageClass2() throws Exception { @@ -147,11 +139,12 @@ public final class TestSimpleFileRead extends TestCase { for (String messageClass : new String[]{ "Appointment", "Contact", "Post", "StickyNote", "Task" }) { - MAPIMessage.MESSAGE_CLASS mc = new MAPIMessage( - POIDataSamples.getHSMFInstance().getFile("msgClass"+messageClass+".msg") - ).getMessageClassEnum(); - assertTrue( mc + " but expected " + messageClass, - messageClass.equalsIgnoreCase(mc.toString().replaceAll("_", ""))); + try (MAPIMessage mapiMessage = new MAPIMessage( + POIDataSamples.getHSMFInstance().getFile("msgClass" + messageClass + ".msg"))) { + MAPIMessage.MESSAGE_CLASS mc = mapiMessage.getMessageClassEnum(); + assertTrue(mc + " but expected " + messageClass, + messageClass.equalsIgnoreCase(mc.toString().replaceAll("_", ""))); + } } } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index dab7c2829..6bd3d7328 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -98,7 +98,6 @@ public final class TestHSSFSheet extends BaseTestSheet { wb.close(); } - @Test public void getSetMargin() throws IOException { baseTestGetSetMargin(new double[]{0.75, 0.75, 1.0, 1.0, 0.3, 0.3}); @@ -156,7 +155,7 @@ public final class TestHSSFSheet extends BaseTestSheet { /** - * Test WSBboolRecord fields get set in the user model. + * Test WSBoolRecord fields get set in the user model. */ @Test public void wsBool() throws IOException { @@ -166,6 +165,7 @@ public final class TestHSSFSheet extends BaseTestSheet { (WSBoolRecord) s.getSheet().findFirstRecordBySid(WSBoolRecord.sid); // Check defaults + assertNotNull(record); assertTrue(record.getAlternateExpression()); assertTrue(record.getAlternateFormula()); assertFalse(record.getAutobreaks()); @@ -518,7 +518,9 @@ public final class TestHSSFSheet extends BaseTestSheet { sheet.setZoom(75); assertTrue(sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid) > 0); SCLRecord sclRecord = (SCLRecord) sheet.getSheet().findFirstRecordBySid(SCLRecord.sid); - assertEquals(75, 100*sclRecord.getNumerator()/sclRecord.getDenominator()); + assertNotNull(sclRecord); + short numerator = sclRecord.getNumerator(); + assertEquals(75, 100* numerator /sclRecord.getDenominator()); int sclLoc = sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid); int window2Loc = sheet.getSheet().findFirstRecordLocBySid(WindowTwoRecord.sid); @@ -942,6 +944,7 @@ public final class TestHSSFSheet extends BaseTestSheet { // Details checks HSSFCellStyle bs = wbSimple.getSheetAt(0).getColumnStyle(1); + assertNotNull(bs); assertEquals(62, bs.getIndex()); assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", bs.getDataFormatString()); assertEquals("Calibri", bs.getFont(wbSimple).getFontName()); @@ -952,6 +955,7 @@ public final class TestHSSFSheet extends BaseTestSheet { HSSFCellStyle cs = wbComplex.getSheetAt(0).getColumnStyle(1); + assertNotNull(cs); assertEquals(62, cs.getIndex()); assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", cs.getDataFormatString()); assertEquals("Arial", cs.getFont(wbComplex).getFontName()); @@ -1023,6 +1027,7 @@ public final class TestHSSFSheet extends BaseTestSheet { sh = wb2.getSheetAt(0); ish = sh.getSheet(); ObjRecord objRecord = (ObjRecord)ish.findFirstRecordBySid(ObjRecord.sid); + assertNotNull(objRecord); List subRecords = objRecord.getSubRecords(); assertEquals(3, subRecords.size()); assertTrue(subRecords.get(0) instanceof CommonObjectDataSubRecord ); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java index 33dfb308d..70bb3b887 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java @@ -17,11 +17,6 @@ package org.apache.poi.hssf.usermodel; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import org.apache.poi.hssf.HSSFTestDataSamples; @@ -30,13 +25,12 @@ import org.apache.poi.hssf.record.BackupRecord; import org.apache.poi.hssf.record.LabelSSTRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Name; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.junit.Test; +import static org.junit.Assert.*; + /** * Class to test Workbook functionality */ @@ -71,19 +65,8 @@ public final class TestWorkbook { HSSFWorkbook wb1 = new HSSFWorkbook(); HSSFSheet s = wb1.createSheet(); - for (int rownum = 0; rownum < 100; rownum++) { - HSSFRow r = s.createRow(rownum); + populateSheet(s); - for (int cellnum = 0; cellnum < 50; cellnum += 2) { - HSSFCell c = r.createCell(cellnum); - c.setCellValue(rownum * 10000 + cellnum - + ((( double ) rownum / 1000) - + (( double ) cellnum / 10000))); - c = r.createCell(cellnum + 1); - c.setCellValue(new HSSFRichTextString("TEST")); - } - } - HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1); sanityChecker.checkHSSFWorkbook(wb1); @@ -112,18 +95,8 @@ public final class TestWorkbook { HSSFWorkbook wb1 = new HSSFWorkbook(); HSSFSheet s = wb1.createSheet(); - for (int rownum = 0; rownum < 100; rownum++) { - HSSFRow r = s.createRow(rownum); + populateSheet(s); - for (int cellnum = 0; cellnum < 50; cellnum += 2) { - HSSFCell c = r.createCell(cellnum); - c.setCellValue(rownum * 10000 + cellnum - + ((( double ) rownum / 1000) - + (( double ) cellnum / 10000))); - c = r.createCell(cellnum + 1); - c.setCellValue(new HSSFRichTextString("TEST")); - } - } for (int rownum = 0; rownum < 25; rownum++) { HSSFRow r = s.getRow(rownum); s.removeRow(r); @@ -411,18 +384,8 @@ public final class TestWorkbook { HSSFWorkbook wb1 = new HSSFWorkbook(); HSSFSheet s = wb1.createSheet(); - for (int rownum = 0; rownum < 100; rownum++) { - HSSFRow r = s.createRow(rownum); + populateSheet(s); - for (int cellnum = 0; cellnum < 50; cellnum += 2) { - HSSFCell c = r.createCell(cellnum); - c.setCellValue(rownum * 10000 + cellnum - + ((( double ) rownum / 1000) - + (( double ) cellnum / 10000))); - c = r.createCell(cellnum + 1); - c.setCellValue(new HSSFRichTextString("TEST")); - } - } s.addMergedRegion(new CellRangeAddress(0, 10, 0, 10)); s.addMergedRegion(new CellRangeAddress(30, 40, 5, 15)); sanityChecker.checkHSSFWorkbook(wb1); @@ -434,11 +397,26 @@ public final class TestWorkbook { confirmRegion(new CellRangeAddress(0, 10, 0, 10), r1); confirmRegion(new CellRangeAddress(30, 40,5, 15), r2); - + wb2.close(); wb1.close(); } + private void populateSheet(Sheet s) { + for (int rownum = 0; rownum < 100; rownum++) { + Row r = s.createRow(rownum); + + for (int cellnum = 0; cellnum < 50; cellnum += 2) { + Cell c = r.createCell(cellnum); + c.setCellValue(rownum * 10000 + cellnum + + ((( double ) rownum / 1000) + + (( double ) cellnum / 10000))); + c = r.createCell(cellnum + 1); + c.setCellValue(new HSSFRichTextString("TEST")); + } + } + } + private static void confirmRegion(CellRangeAddress ra, CellRangeAddress rb) { assertEquals(ra.getFirstRow(), rb.getFirstRow()); assertEquals(ra.getLastRow(), rb.getLastRow()); @@ -448,7 +426,6 @@ public final class TestWorkbook { /** * Test the backup field gets set as expected. - * @throws IOException */ @Test public void testBackupRecord() throws IOException { @@ -490,7 +467,6 @@ public final class TestWorkbook { * This tests is for bug [ #506658 ] Repeating output. * * We need to make sure only one LabelSSTRecord is produced. - * @throws IOException */ @Test public void testRepeatingBug() throws IOException { @@ -501,6 +477,7 @@ public final class TestWorkbook { cell.setCellValue(new HSSFRichTextString("Class")); cell = row.createCell(2); + assertNotNull(cell); RecordCounter rc = new RecordCounter(); sheet.getSheet().visitContainedRecords(rc, 0); @@ -584,12 +561,16 @@ public final class TestWorkbook { try { sheet.setRepeatingColumns(cra); fail("invalid start index is ignored"); - } catch (IllegalArgumentException e) {} + } catch (IllegalArgumentException e) { + // expected here + } try { sheet.setRepeatingRows(cra); fail("invalid start index is ignored"); - } catch (IllegalArgumentException e) {} + } catch (IllegalArgumentException e) { + // expected here + } sheet.setRepeatingColumns(null); sheet.setRepeatingRows(null); @@ -599,39 +580,6 @@ public final class TestWorkbook { workbook.close(); } - @Test - public void testAddMergedRegionWithRegion() throws IOException { - HSSFWorkbook wb1 = new HSSFWorkbook(); - HSSFSheet s = wb1.createSheet(); - - for (int rownum = 0; rownum < 100; rownum++) { - HSSFRow r = s.createRow(rownum); - - for (int cellnum = 0; cellnum < 50; cellnum += 2) { - HSSFCell c = r.createCell(cellnum); - c.setCellValue(rownum * 10000 + cellnum - + ((( double ) rownum / 1000) - + (( double ) cellnum / 10000))); - c = r.createCell(cellnum + 1); - c.setCellValue(new HSSFRichTextString("TEST")); - } - } - s.addMergedRegion(new CellRangeAddress(0, 10, 0, 10)); - s.addMergedRegion(new CellRangeAddress(30, 40, 5, 15)); - sanityChecker.checkHSSFWorkbook(wb1); - HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1); - - s = wb2.getSheetAt(0); - CellRangeAddress r1 = s.getMergedRegion(0); - CellRangeAddress r2 = s.getMergedRegion(1); - - confirmRegion(new CellRangeAddress(0, 10, 0, 10), r1); - confirmRegion(new CellRangeAddress(30, 40,5, 15), r2); - - wb2.close(); - wb1.close(); - } - @Test public void testBug58085RemoveSheetWithNames() throws Exception { HSSFWorkbook wb1 = new HSSFWorkbook(); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java index 1c15804fb..08414cd5c 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java @@ -18,7 +18,6 @@ package org.apache.poi.ss.usermodel; import org.apache.poi.common.usermodel.HyperlinkType; -import org.apache.poi.hssf.usermodel.*; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.util.CellAddress; @@ -37,8 +36,9 @@ import static org.junit.Assert.*; import static org.junit.Assume.assumeTrue; /** - * Common superclass for testing {@link HSSFCell}, org.apache.poi.xssf.usermodel.XSSFCell and - * org.apache.poi.xssf.streaming.SXSSFCell + * Common superclass for testing {@link org.apache.poi.hssf.usermodel.HSSFCell}, + * {@link org.apache.poi.xssf.usermodel.XSSFCell} and + * {@link org.apache.poi.xssf.streaming.SXSSFCell} */ public abstract class BaseTestSheet { private static final int ROW_COUNT = 40000;