public class ExcelWorkbookImporter
extends java.lang.Object
Provides functionality for importing content from an Excel workbook into a presentation.
| Modifier and Type | Method and Description |
|---|---|
static IChart |
addChartFromWorkbook(IShapeCollection shapes,
float x,
float y,
IExcelDataWorkbook workbook,
java.lang.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.
|
static IChart |
addChartFromWorkbook(IShapeCollection shapes,
float x,
float y,
IExcelDataWorkbook workbook,
java.lang.String worksheetName,
java.lang.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.
|
static IChart |
addChartFromWorkbook(IShapeCollection shapes,
float x,
float y,
java.io.InputStream workbookStream,
java.lang.String worksheetName,
java.lang.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.
|
static IChart |
addChartFromWorkbook(IShapeCollection shapes,
float x,
float y,
java.lang.String workbookPath,
java.lang.String worksheetName,
java.lang.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.
|
public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, java.lang.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(); }
shapes - The shape collection to which the chart will be added.x - The X coordinate for positioning the chart.y - The Y coordinate for positioning the chart.workbook - The Excel workbook.worksheetName - The name of the worksheet that contains the chart.chartIndex - The zero-based index of the chart shape to insert.
This index can be obtained using the IExcelDataWorkbook.getChartsFromWorksheet(String) method.embedAllWorkbook - If true, the entire workbook will be embedded in the chart;
if false, only the chart data will be embedded.com.aspose.ms.System.ArgumentException - Thrown when any required parameter is null, empty, or if the chart cannot be found in the workbook.public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, IExcelDataWorkbook workbook, java.lang.String worksheetName, java.lang.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(); }
shapes - The shape collection to which the chart will be added.x - The X coordinate for positioning the chart.y - The Y coordinate for positioning the chart.workbook - The Excel workbook.worksheetName - The name of the worksheet that contains the chart.chartName - The name of the chart to be added.embedAllWorkbook - If true, the entire workbook will be embedded in the chart;
if false, only the chart data will be embedded.com.aspose.ms.System.ArgumentException - Thrown when any required parameter is null, empty, or if the chart cannot be found in the workbook.public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, java.io.InputStream workbookStream, java.lang.String worksheetName, java.lang.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(); }
shapes - The shape collection to which the chart will be added.x - The X coordinate for positioning the chart.y - The Y coordinate for positioning the chart.workbookStream - A stream containing the workbook data.worksheetName - The name of the worksheet that contains the chart.chartName - The name of the chart to be added.embedAllWorkbook - If true, the entire workbook will be embedded in the chart;
if false, only the chart data will be embedded.com.aspose.ms.System.ArgumentException - Thrown when any required parameter is null, empty, or if the chart cannot be found in the workbook.com.aspose.ms.System.InvalidOperationException - Thrown when the input data is in an unsupported format.public static IChart addChartFromWorkbook(IShapeCollection shapes, float x, float y, java.lang.String workbookPath, java.lang.String worksheetName, java.lang.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(); }
shapes - The shape collection to which the chart will be added.x - The X coordinate for positioning the chart.y - The Y coordinate for positioning the chart.workbookPath - The file path to the workbook containing the chart.worksheetName - The name of the worksheet that contains the chart.chartName - The name of the chart to be added.embedWorkbook - If true, the workbook will be embedded in the chart;
if false, the chart will link to the external workbook.com.aspose.ms.System.ArgumentException - Thrown when any required parameter is null, empty, or if the chart cannot be found in the workbook.com.aspose.ms.System.IO.IOException - Thrown when an I/O error occurs while accessing the file.com.aspose.ms.System.InvalidOperationException - Thrown when the input data is in an unsupported format.Copyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.