Copying Charts from Excel fails

1

I want to copy a chart from Excel.

var chart = (ChartObject)allCharts.Item("SomeChart");
chart.Select();
chart.Copy();

The problem is, for some chart types copying failes with Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL)):

  • Treemap
  • Waterfall
  • Sunburst
  • Funnel
  • Histogram
  • Pareto
  • Box and Whisker

As I am not sure, whether this is a full list, I want to somehow check the chart object before copying it.

So far, I found out two clues:

  • There is a _Chart.Type, which is "Reserved for internal use." as Microsoft states. The Type gets a value of -1 for the objects above and some other values otherwise.

  • _Chart.ChartType Enum seems not to include the objects above and returns an int value and no names like XlChartType.xlPieExploded.

The question is, can I rely on any of these two peculiarities or is there another way to prevent copy failure?

c#
excel
office-interop
office-addins
excel-addins
asked on Stack Overflow Jun 12, 2018 by pheeria • edited Jun 12, 2018 by pheeria

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0