SpreadsheetDocument extends Document implements ChartContainer { public Chart createChart(String title, DataSet dataset, Rectangle rect) { return getChartContainerImpl().createChart(title, dataset, rect); } 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 testCreateChart() throws Exception{ try { SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(ResourceUtilities.getAbsolutePath(TEST_FILE)); String title = "XXXTitle"; String[] lables = new String[]{"spring","summer","autumn","autumn"}; String[] legends = new String[]{"hello1","hello2","hello3"}; double[][] data = new double[][]{{1.2,2.22,3},{2,3,4},{3,4,5},{4,5,6}}; DataSet dataset = new DataSet(lables, legends, data); Rectangle rect = new Rectangle(); rect.x = 367; rect.y = 389; rect.width = 379; rect.height = 424; Chart spChart = spDocument.createChart(title, dataset, rect); Assert.assertNotNull(spChart); spChart.setChartType(ChartType.AREA); spDocument.save(ResourceUtilities.getTestOutput("Chart_"+TEST_FILE)); Assert.assertEquals(dataset, spChart.getChartData()); Assert.assertEquals("XXXTitle", spChart.getChartTitle()); Assert.assertEquals(ChartType.AREA, spChart.getChartType()); LOG.log(Level.INFO,"spChart--> " + spChart); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage(), e); Assert.fail(e.getMessage()); } }