AddChartFromWorkbook()

ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection>, float, float, System::SharedPtr<Aspose::Slides::Excel::IExcelDataWorkbook>, System::String, int32_t, bool) method

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

static System::SharedPtr<Aspose::Slides::Charts::IChart> Aspose::Slides::Import::ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection> shapes, float x, float y, System::SharedPtr<Aspose::Slides::Excel::IExcelDataWorkbook> workbook, System::String worksheetName, int32_t chartIndex, bool embedAllWorkbook)

Arguments

ParameterTypeDescription
shapesSystem::SharedPtr<Aspose::Slides::IShapeCollection>The shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookSystem::SharedPtr<Aspose::Slides::Excel::IExcelDataWorkbook>The Excel workbook.
worksheetNameSystem::StringThe name of the worksheet that contains the chart.
chartIndexint32_tThe zero-based index of the chart shape to insert. This index can be obtained using the IExcelDataWorkbook::GetChartsFromWorksheet(string) method.
embedAllWorkbookboolIf true, the entire workbook will be embedded in the chart; if false, only the chart data will be embedded.

Return Value

The chart that was added to the shape collection.

Remarks

Example:

System::SharedPtr<IExcelDataWorkbook> wb = System::MakeObject<ExcelDataWorkbook>(testFile);
auto pres = System::MakeObject<Presentation>();
ExcelWorkbookImporter::AddChartFromWorkbook(pres->get_Slide(0)->get_Shapes(), 10.0f, 10.0f, wb, worksheetName, chartName, false);
pres->Save(u"result.pptx", SaveFormat::Pptx);

ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection>, float, float, System::SharedPtr<Aspose::Slides::Excel::IExcelDataWorkbook>, System::String, System::String, bool) method

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

static System::SharedPtr<Aspose::Slides::Charts::IChart> Aspose::Slides::Import::ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection> shapes, float x, float y, System::SharedPtr<Aspose::Slides::Excel::IExcelDataWorkbook> workbook, System::String worksheetName, System::String chartName, bool embedAllWorkbook)

Arguments

ParameterTypeDescription
shapesSystem::SharedPtr<Aspose::Slides::IShapeCollection>The shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookSystem::SharedPtr<Aspose::Slides::Excel::IExcelDataWorkbook>The Excel workbook.
worksheetNameSystem::StringThe name of the worksheet that contains the chart.
chartNameSystem::StringThe name of the chart to be added.
embedAllWorkbookboolIf true, the entire workbook will be embedded in the chart; if false, only the chart data will be embedded.

Return Value

The chart that was added to the shape collection.

Remarks

Example:

System::SharedPtr<IExcelDataWorkbook> wb = System::MakeObject<ExcelDataWorkbook>(testFile);
auto pres = System::MakeObject<Presentation>();

System::String worksheetName = u"worksheet name";
auto worksheetCharts = wb->GetChartsFromWorksheet(worksheetName);
for (auto&& chart : worksheetCharts)
{
    System::SharedPtr<ISlide> slide = pres->get_Slides()->AddEmptySlide(pres->get_LayoutSlides()->idx_get(0));
    ExcelWorkbookImporter::AddChartFromWorkbook(slide->get_Shapes(), 10.0f, 10.0f, wb, worksheetName, chart.get_Key(), false);
}
pres->Save(u"result.pptx", SaveFormat::Pptx);

ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection>, float, float, System::SharedPtr<System::IO::Stream>, System::String, System::String, bool) method

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

static System::SharedPtr<Aspose::Slides::Charts::IChart> Aspose::Slides::Import::ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection> shapes, float x, float y, System::SharedPtr<System::IO::Stream> workbookStream, System::String worksheetName, System::String chartName, bool embedAllWorkbook)

Arguments

ParameterTypeDescription
shapesSystem::SharedPtr<Aspose::Slides::IShapeCollection>The shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookStreamSystem::SharedPtr<System::IO::Stream>A stream containing the workbook data.
worksheetNameSystem::StringThe name of the worksheet that contains the chart.
chartNameSystem::StringThe name of the chart to be added.
embedAllWorkbookboolIf true, the entire workbook will be embedded in the chart; if false, only the chart data will be embedded.

Return Value

The chart that was added to the shape collection.

Remarks

Example:

auto fStream = System::MakeObject<System::IO::FileStream>(workbookPath, System::IO::FileMode::Open, System::IO::FileAccess::Read);
auto pres = System::MakeObject<Presentation>();
ExcelWorkbookImporter::AddChartFromWorkbook(pres->get_LayoutSlides()->idx_get(0)->get_Shapes(), 10.0f, 10.0f, fStream, worksheetName, chartName, true);
pres->Save(u"result.pptx", SaveFormat::Pptx);

ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection>, float, float, System::String, System::String, System::String, bool) method

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

static System::SharedPtr<Aspose::Slides::Charts::IChart> Aspose::Slides::Import::ExcelWorkbookImporter::AddChartFromWorkbook(System::SharedPtr<Aspose::Slides::IShapeCollection> shapes, float x, float y, System::String workbookPath, System::String worksheetName, System::String chartName, bool embedWorkbook)

Arguments

ParameterTypeDescription
shapesSystem::SharedPtr<Aspose::Slides::IShapeCollection>The shape collection to which the chart will be added.
xfloatThe X coordinate for positioning the chart.
yfloatThe Y coordinate for positioning the chart.
workbookPathSystem::StringThe file path to the workbook containing the chart.
worksheetNameSystem::StringThe name of the worksheet that contains the chart.
chartNameSystem::StringThe name of the chart to be added.
embedWorkbookboolIf true, the workbook will be embedded in the chart; if false, the chart will link to the external workbook.

Return Value

The chart that was added to the shape collection.

Remarks

Example:

auto pres = System::MakeObject<Presentation>();
ExcelWorkbookImporter::AddChartFromWorkbook(pres->get_Slide(0)->get_Shapes(), 10.0f, 10.0f, workbookPath, worksheetName, chartName, false);
pres->Save(u"result.pptx", SaveFormat::Pptx);

See Also