SetExternalWorkbook

SetExternalWorkbook(string)

Sets external workbook as a data source for the chart. Chart data will be updated from the target workbook.

public void SetExternalWorkbook(string workbookPath)
ParameterTypeDescription
workbookPathStringPath to the target workbook

Exceptions

exceptioncondition
InvalidOperationExceptionExternal workbook is not available or can’t be loaded.

Examples

[C#]
using (Presentation pres = new Presentation())

   IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, true);
   IChartData chartData = chart.ChartData;
   (chartData as ChartData).SetExternalWorkbook("../../workbook.xlsx");

See Also


SetExternalWorkbook(string, bool)

Sets external workbook as a data source for the chart.

public void SetExternalWorkbook(string workbookPath, bool updateChartData)
ParameterTypeDescription
workbookPathStringPath to the target workbook
updateChartDataBooleanIf value is false only workbook path will be updated. Chart data won’t be loaded and updated from the target workbook. Can be used when target workbook doesn’t exist or it’s not available. If value is true chart data will be updated from the target workbook.

Exceptions

exceptioncondition
InvalidOperationExceptionExternal workbook is not available or can’t be loaded.

Examples

using (Presentation pres = new Presentation())

   IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, true);
   IChartData chartData = chart.ChartData;

   (chartData as ChartData).SetExternalWorkbook("http://path/doesnt/exists", false);

See Also