Excel:可以通过哪种方式创buildChartGroups?

我有一个Chart包含两个ChartGroup 。 我从来没有故意这样做过,所以我猜不出是什么原因造成的。 任何人都可以提供所有选项(无论是VBA或其他)?

如果我知道可能采取的行动是什么,我可以意识到并控制/避免它们。

PS:这个缺点是我有很多使用PlotOrder识别Series的代码。 如果有多个ChartGroup ,则PlotOrder不是Chart Series的唯一标识符(它在ChartGroup是唯一的)。 从长远来看,无论如何,我将不得不调整我的代码。 但是目前来说,我可以尽可能地将图表调整为拥有一个ChartGroup 。 有没有简单的方法来重新分配一个SeriesChartGroup ? (这将使一个单一的职位有两个问题…)

这个问题源于

Excel:图表中两个系列的重复PlotOrder

编辑 :我在这里列出一些有趣的发现(围绕这个主题,但不回答具体问题)。

  1. 我在官方网站find了这个

    ChartGroups Collection :“ 指定图表中所有ChartGroup对象的集合,每个ChartGroup对象表示一个或多个以相同格式绘制在一个图表中的系列。 ”即使我没有明确指出它,似乎每个XlChartType (一个Series.ChartTypeEnumerationtypes)显然会和一个给定的格式相关联,例如带有scatter的xlXYScatter

    ChartGroup对象 :“ 表示一个或多个以相同格式在图表中绘制的系列。

  2. ChartGroup所有Series应具有相同的“ 格式 ”。 但是相反的情况是不正确的:在不同的ChartGroup可能有相同格式的ChartGroup 。 请参阅下面的第3点和示例。

  3. 从ChartGroup对象 :“ 因为如果用于该组的图表格式发生更改,特定图表组的索引号可能会更改,则使用其中一个指定的图表组快捷方式可能会更容易返回特定的图表组。方法返回图表中饼图组的集合,LineGroups方法返回折线图组的集合,依此类推。 “例如, LineGroups Method 。

    这允许点2: PieGroups将返回ChartGroup的集合。 可能有不止一个这样的ChartGroup ,并且所有的系列将具有Pie格式。

  4. 返回特定图表组的可用命名图表组快捷方式并不全面。 例如,没有XYScatterGroups方法。

作为第二点的例子,我有一个XYScatter格式的图表。 5个可用的XlChartType (根据XlChartType Enumeration的数值和描述)是

 xlXYScatter -4169 Scatter. xlXYScatterSmooth 72 Scatter with Smoothed Lines. xlXYScatterSmoothNoMarkers 73 Scatter with Smoothed Lines and No Data Markers. xlXYScatterLines 74 Scatter with Lines. xlXYScatterLinesNoMarkers 75 Scatter with Lines and No Data Markers. 

在图表中,有2个ChartGroups,如转储(从一个自定义Sub中所示)

 ChartObject 'Chart 36', no. series: 6 * ChartGroup, .Index: 1, no. series: 2 ** plot order: 1, type: -4169, chart: 'Chart 36', chart type: 73, no. points: 17 ** plot order: 2, type: -4169, chart: 'Chart 36', chart type: -4169, no. points: 17 * ChartGroup, .Index: 2, no. series: 4 ** plot order: 1, type: -4169, chart: 'Chart 36', chart type: 75, no. points: 2 ** plot order: 2, type: -4169, chart: 'Chart 36', chart type: -4169, no. points: 24 ** plot order: 3, type: -4169, chart: 'Chart 36', chart type: 75, no. points: 33 ** plot order: 4, type: -4169, chart: 'Chart 36', chart type: -4169, no. points: 5 

请注意,两个ChartGroup中都有一系列types的xlXYScatter (-4169)。 我可以将ChartGroup 1的Series 2的格式更改为5种types中的任何一种,并且不会更改ChartGroup