diff --git a/pom.xml b/pom.xml index f2052037..e6165c49 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ org.apache.poi poi-ooxml - 3.16 + 3.17 org.apache.poi @@ -139,7 +139,7 @@ com.fasterxml.jackson.core jackson-databind - 2.8.8 + 2.8.10 diff --git a/src/main/java/com/monitorjbl/xlsx/StreamingReader.java b/src/main/java/com/monitorjbl/xlsx/StreamingReader.java index d4c337c8..bd9d3360 100644 --- a/src/main/java/com/monitorjbl/xlsx/StreamingReader.java +++ b/src/main/java/com/monitorjbl/xlsx/StreamingReader.java @@ -15,6 +15,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.StaxHelper; import org.apache.poi.xssf.eventusermodel.XSSFReader; import org.apache.poi.xssf.model.SharedStringsTable; import org.apache.poi.xssf.model.StylesTable; @@ -24,7 +25,6 @@ import org.w3c.dom.NodeList; import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import java.io.File; import java.io.FileOutputStream; @@ -358,7 +358,7 @@ public StreamingReader read(File f) { throw new MissingSheetException("Unable to find sheet at index [" + sheetIndex + "]"); } - XMLEventReader parser = XMLInputFactory.newInstance().createXMLEventReader(sheet); + XMLEventReader parser = StaxHelper.newXMLInputFactory().createXMLEventReader(sheet); return new StreamingReader(new StreamingWorkbookReader(sst, sstCache, pkg, new StreamingSheetReader(sst, styles, parser, use1904Dates, rowCacheSize), this)); diff --git a/src/main/java/com/monitorjbl/xlsx/impl/StreamingSheet.java b/src/main/java/com/monitorjbl/xlsx/impl/StreamingSheet.java index 1ce14948..93871e17 100644 --- a/src/main/java/com/monitorjbl/xlsx/impl/StreamingSheet.java +++ b/src/main/java/com/monitorjbl/xlsx/impl/StreamingSheet.java @@ -544,14 +544,6 @@ public boolean getScenarioProtect() { throw new UnsupportedOperationException(); } - /** - * Not supported - */ - @Override - public void setZoom(int numerator, int denominator) { - throw new UnsupportedOperationException(); - } - /** * Not supported */ @@ -816,14 +808,6 @@ public void autoSizeColumn(int column, boolean useMergedCells) { throw new UnsupportedOperationException(); } - /** - * Not supported - */ - @Override - public Comment getCellComment(int row, int column) { - throw new UnsupportedOperationException(); - } - /** * Not supported */ diff --git a/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbook.java b/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbook.java index 31e1de95..46e33c9e 100644 --- a/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbook.java +++ b/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbook.java @@ -231,14 +231,6 @@ public Font createFont() { throw new UnsupportedOperationException(); } - /** - * Not supported - */ - @Override - public Font findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) { - throw new UnsupportedOperationException(); - } - /** * Not supported */ diff --git a/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbookReader.java b/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbookReader.java index 5a16c396..a3569f24 100644 --- a/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbookReader.java +++ b/src/main/java/com/monitorjbl/xlsx/impl/StreamingWorkbookReader.java @@ -11,6 +11,7 @@ import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.StaxHelper; import org.apache.poi.xssf.eventusermodel.XSSFReader; import org.apache.poi.xssf.eventusermodel.XSSFReader.SheetIterator; import org.apache.poi.xssf.model.SharedStringsTable; @@ -21,7 +22,6 @@ import org.w3c.dom.NodeList; import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import java.io.File; import java.io.FileOutputStream; @@ -156,7 +156,7 @@ void loadSheets(XSSFReader reader, SharedStringsTable sst, StylesTable stylesTab //Iterate over the loaded streams int i = 0; for(URI uri : sheetStreams.keySet()) { - XMLEventReader parser = XMLInputFactory.newInstance().createXMLEventReader(sheetStreams.get(uri)); + XMLEventReader parser = StaxHelper.newXMLInputFactory().createXMLEventReader(sheetStreams.get(uri)); sheets.add(new StreamingSheet(sheetProperties.get(i++).get("name"), new StreamingSheetReader(sst, stylesTable, parser, use1904Dates, rowCacheSize))); } } diff --git a/src/main/java/com/monitorjbl/xlsx/sst/BufferedStringsTable.java b/src/main/java/com/monitorjbl/xlsx/sst/BufferedStringsTable.java index 4d738ac6..073e29ef 100644 --- a/src/main/java/com/monitorjbl/xlsx/sst/BufferedStringsTable.java +++ b/src/main/java/com/monitorjbl/xlsx/sst/BufferedStringsTable.java @@ -3,12 +3,12 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackagePart; +import org.apache.poi.util.StaxHelper; import org.apache.poi.xssf.model.SharedStringsTable; import org.apache.poi.xssf.usermodel.XSSFRelation; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst; import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.events.XMLEvent; import java.io.File; @@ -33,8 +33,7 @@ private BufferedStringsTable(PackagePart part, File file, int cacheSize) throws @Override public void readFrom(InputStream is) throws IOException { try { - XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); - XMLEventReader xmlEventReader = xmlInputFactory.createXMLEventReader(is); + XMLEventReader xmlEventReader = StaxHelper.newXMLInputFactory().createXMLEventReader(is); while(xmlEventReader.hasNext()) { XMLEvent xmlEvent = xmlEventReader.nextEvent(); diff --git a/src/test/java/com/monitorjbl/xlsx/StreamingWorkbookTest.java b/src/test/java/com/monitorjbl/xlsx/StreamingWorkbookTest.java index 251a0020..43b6bd6d 100644 --- a/src/test/java/com/monitorjbl/xlsx/StreamingWorkbookTest.java +++ b/src/test/java/com/monitorjbl/xlsx/StreamingWorkbookTest.java @@ -1,9 +1,6 @@ package com.monitorjbl.xlsx; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.junit.BeforeClass; import org.junit.Test; @@ -13,8 +10,6 @@ import java.util.Iterator; import java.util.Locale; -import static org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA; -import static org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -98,8 +93,8 @@ public void testFormulaCells() throws Exception { Row row3 = rowIterator.next(); Cell A3 = row3.getCell(0); - assertEquals("Cell A3 should be of type formula", CELL_TYPE_FORMULA, A3.getCellType()); - assertEquals("Cell A3's value should be of type numeric", CELL_TYPE_NUMERIC, A3.getCachedFormulaResultType()); + assertEquals("Cell A3 should be of type formula", CellType.FORMULA, A3.getCellTypeEnum()); + assertEquals("Cell A3's value should be of type numeric", CellType.NUMERIC, A3.getCachedFormulaResultTypeEnum()); assertEquals("Wrong formula", "SUM(A1:A2)", A3.getCellFormula()); } }