删除所有现有的Excel图表系列 [英] Delete all existing excel chart series

查看:79
本文介绍了删除所有现有的Excel图表系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用excel修改折线图,我想删除所有系列并将新系列添加到同一图表。

I am modifying a line chart in excel and I want to remove all the series and add new series to the same chart.

我正在使用以下代码:

I am using the foll code:

Excel.SeriesCollection serColl = chartpage.SeriesCollection();
Excel.Series ser = serColl.Item(4);
ser.Delete();
ser = serColl.Item(3);
ser.Delete();
ser = serColl.Item(2);
ser.Delete();
ser = serColl.Item(1);
ser.Delete();

但是我希望代码是通用的,即找到序列号并循环删除全部。
预先感谢。

But I wanted the code to be generic i.e. find the number of series and delete all in a loop. Thanks in advance.

推荐答案

就像这样。

Excel.SeriesCollection serColl = chartpage.SeriesCollection();
while(seriesColl.Count > 0)
{
        seriesColl.Item(1).Delete();
}

这篇关于删除所有现有的Excel图表系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆