ExcelWorkbookImporter

Inheritance: java.lang.Object

public class ExcelWorkbookImporter

Provides functionality for importing content from an Excel workbook into a presentation.

Methods

MethodDescription
addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, String worksheetName, int chartIndex, boolean embedAllWorkbook)Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.
addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, String worksheetName, String chartName, boolean embedAllWorkbook)Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.
addChartFromWorkbook(IShapeCollection shapes, float x, float y, InputStream workbookStream, String worksheetName, String chartName, boolean embedAllWorkbook)Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.
addChartFromWorkbook(IShapeCollection shapes, float x, float y, String workbookPath, String worksheetName, String chartName, boolean embedWorkbook)Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.

addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, String worksheetName, int chartIndex, boolean embedAllWorkbook)

public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, String worksheetName, int chartIndex, boolean embedAllWorkbook)

Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.


Example:
 
 IExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 Presentation pres = new Presentation();
 try {
     ExcelWorkbookImporter.addChartFromWorkbook(pres.getSlides().get_Item(0).getShapes(), 10, 10, wb, worksheetName, chartName, false);
     pres.save("result.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
shapesIShapeCollectionThe shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookIExcelDataWorkbookThe Excel workbook.
worksheetNamejava.lang.StringThe name of the worksheet that contains the chart.
chartIndexintThe zero-based index of the chart shape to insert. This index can be obtained using the IExcelDataWorkbook.getChartsFromWorksheet(String) method.
embedAllWorkbookbooleanIf true, the entire workbook will be embedded in the chart; if false, only the chart data will be embedded.

Returns: IChart - The chart that was added to the shape collection.

addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, String worksheetName, String chartName, boolean embedAllWorkbook)

public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, String worksheetName, String chartName, boolean embedAllWorkbook)

Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.


Example:
 
 IExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 Presentation pres = new Presentation();
 try {
     String worksheetName = "worksheet name";
     Dictionary.Enumerator<Integer, String> worksheetCharts = wb.getChartsFromWorksheet(worksheetName).iterator();
     while (worksheetCharts.hasNext())
     {
         KeyValuePair<Integer, String> chart = worksheetCharts.next();
         ISlide slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
         ExcelWorkbookImporter.addChartFromWorkbook(slide.getShapes(), 10, 10, wb, worksheetName, chart.getKey(), false);
     }
     pres.save("result.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
shapesIShapeCollectionThe shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookIExcelDataWorkbookThe Excel workbook.
worksheetNamejava.lang.StringThe name of the worksheet that contains the chart.
chartNamejava.lang.StringThe name of the chart to be added.
embedAllWorkbookbooleanIf true, the entire workbook will be embedded in the chart; if false, only the chart data will be embedded.

Returns: IChart - The chart that was added to the shape collection.

addChartFromWorkbook(IShapeCollection shapes, float x, float y, InputStream workbookStream, String worksheetName, String chartName, boolean embedAllWorkbook)

public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, InputStream workbookStream, String worksheetName, String chartName, boolean embedAllWorkbook)

Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.


Example:
 
 Presentation pres = new Presentation();
 try {
     FileInputStream fStream = new FileInputStream(workbookPath);
     ExcelWorkbookImporter.addChartFromWorkbook(pres.getLayoutSlides().get_Item(0).getShapes(), 10, 10, fStream, worksheetName, chartName, true);
     fStream.close();
     pres.save("result.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
shapesIShapeCollectionThe shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookStreamjava.io.InputStreamA stream containing the workbook data.
worksheetNamejava.lang.StringThe name of the worksheet that contains the chart.
chartNamejava.lang.StringThe name of the chart to be added.
embedAllWorkbookbooleanIf true, the entire workbook will be embedded in the chart; if false, only the chart data will be embedded.

Returns: IChart - The chart that was added to the shape collection.

addChartFromWorkbook(IShapeCollection shapes, float x, float y, String workbookPath, String worksheetName, String chartName, boolean embedWorkbook)

public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, String workbookPath, String worksheetName, String chartName, boolean embedWorkbook)

Retrieves a chart from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.


Example:
 
 Presentation pres = new Presentation();
 try {
     ExcelWorkbookImporter.addChartFromWorkbook(pres.getSlides().get_Item(0).getShapes(), 10, 10, workbookPath, worksheetName, chartName, false);
     pres.save("result.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
shapesIShapeCollectionThe shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookPathjava.lang.StringThe file path to the workbook containing the chart.
worksheetNamejava.lang.StringThe name of the worksheet that contains the chart.
chartNamejava.lang.StringThe name of the chart to be added.
embedWorkbookbooleanIf true, the workbook will be embedded in the chart; if false, the chart will link to the external workbook.

Returns: IChart - The chart that was added to the shape collection.