SpreadsheetDocument extends Document implements ChartContainer { public static SpreadsheetDocument loadDocument(InputStream inputStream) throws Exception { SpreadsheetDocument document = (SpreadsheetDocument) Document.loadDocument(inputStream); removeDummyCellsFromDocument(document); return document; } protected  SpreadsheetDocument(OdfPackage pkg, String internalPath, SpreadsheetDocument.OdfMediaType odfMediaType); static SpreadsheetDocument newSpreadsheetDocument(); static SpreadsheetDocument newSpreadsheetTemplateDocument(); static SpreadsheetDocument loadDocument(InputStream inputStream); static SpreadsheetDocument loadDocument(String documentPath); static SpreadsheetDocument loadDocument(File file); @Override OfficeSpreadsheetElement getContentRoot(); void changeMode(OdfMediaType mediaType); Table getSheetByIndex(int index); Table getSheetByName(String name); Table getActiveSheet(); Table appendSheet(String name); Table appendSheet(Table refTable, String name); Table insertSheet(int before); Table insertSheet(Table refTable, int before); void removeSheet(int index); int getSheetCount(); OdfElement getTableContainerElement(); Chart createChart(String title, DataSet dataset, Rectangle rect); Chart createChart(String title, SpreadsheetDocument document, CellRangeAddressList cellRangeAddr, boolean firstRowAsLabel,
        boolean firstColumnAsLabel, boolean rowAsDataSeries, Rectangle rect); Chart createChart(String title, String[] labels, String[] legends, double[][] data, Rectangle rect); Chart createChart(String title, SpreadsheetDocument document, CellRangeAddressList cellRangeAddr, boolean firstRowAsLabel,
        boolean firstColumnAsLabel, boolean rowAsDataSeries, Rectangle rect, Cell cell); void deleteChartById(String chartId); void deleteChartByTitle(String title); Chart getChartById(String chartId); List<Chart> getChartByTitle(String title); int getChartCount();  }
@Test public void testGetMediaTypeString() throws Exception{ try { String spreadDocPath = ResourceUtilities.getAbsolutePath(TEST_FILE); SpreadsheetDocument spreadDoc = SpreadsheetDocument.loadDocument(spreadDocPath); Assert.assertNotNull(spreadDoc); OdfMediaType odfMediaType = spreadDoc.getOdfMediaType(); Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE, odfMediaType); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage(), e); Assert.fail(e.getMessage()); } }
@Test public void testGetSuffix() throws Exception{ try { String spreadDocPath = ResourceUtilities.getAbsolutePath(TEST_FILE); SpreadsheetDocument spreadDoc = SpreadsheetDocument.loadDocument(spreadDocPath); Assert.assertNotNull(spreadDoc); OdfMediaType odfMediaType = spreadDoc.getOdfMediaType(); String suffix = odfMediaType.getSuffix(); Assert.assertEquals("ots", suffix); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage(), e); Assert.fail(e.getMessage()); } }
@Test public void testGetOdfMediaType() throws Exception{ try { String spreadDocPath = ResourceUtilities.getAbsolutePath(TEST_FILE); SpreadsheetDocument spreadDoc = SpreadsheetDocument.loadDocument(spreadDocPath); Assert.assertNotNull(spreadDoc); Document.OdfMediaType odfMediaType = SpreadsheetDocument.OdfMediaType.getOdfMediaType(spreadDoc.getMediaTypeString()); Assert.assertEquals("ots", odfMediaType.getSuffix()); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage(), e); Assert.fail(e.getMessage()); } }
@Test public void testLoadDocument() throws Exception{ try { String filePath = ResourceUtilities.getAbsolutePath(TEST_FILE); SpreadsheetDocument spreadDoc = SpreadsheetDocument.loadDocument(filePath); Assert.assertNotNull(spreadDoc); Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE, spreadDoc.getOdfMediaType()); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage(), e); Assert.fail(e.getMessage()); } }
@Test public void testLoadDocumentFile() throws Exception{ try { String filePath = ResourceUtilities.getAbsolutePath(TEST_FILE); File fileDoc = new File(filePath); SpreadsheetDocument spreadDoc = SpreadsheetDocument.loadDocument(fileDoc);; Assert.assertNotNull(spreadDoc); Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE, spreadDoc.getOdfMediaType()); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage(), e); Assert.fail(e.getMessage()); } }