如何用matlab清除excel中已有的图形?

时间:2021-12-26 07:14:02

I have an excel that is connected to matlab through active server. I am generating a graph via matlab and export it to excel. However, I need to clear the existing graphs first so it won't overwrite and make a stacked of graphs.

我有一个通过active server连接到matlab的excel。我正在用matlab生成一个图形并导出到excel中。但是,我需要先清除现有的图,这样它就不会覆盖并生成一堆图。

My idea is to find the existing graph first, and clear it. But, so far, I still don't know how to do it.

我的想法是先找到已有的图,然后清除它。但是,到目前为止,我还不知道怎么做。

Anyone knows? I am open to any suggestions.

有人知道吗?我愿意接受任何建议。

Thank you so much!

谢谢你这么多!

Elizabeth

伊丽莎白

edit:

编辑:

this is a matlab script

这是一个matlab脚本

Excel = actxserver ('Excel.Application'); 
filename = 'xxx'
invoke(Excel.Workbooks,'Open',filename);
Sheets = Excel.ActiveWorkBook.Sheets;
Sheets.Item('Graphs').Activate;
ActiveSheets = Excel.Activesheet;
plotpie(cost,init_stage)
Shapes = ActiveSheets.Shapes;
ActiveSheets.Shapes.AddPicture('location', 0, 1, 400, 325, 345, 230) 

1 个解决方案

#1


0  

Great questions. I can't leave comments so I'll respond here.

伟大的问题。我不能留下评论,所以我在这里回复。

Perhaps one of these will work for you.

也许其中一个对你有用。

ActiveSheet.Shapes.Delete
ActiveSheet.DrawingObjects.Delete
ActiveSheet.Pictures.Delete

#1


0  

Great questions. I can't leave comments so I'll respond here.

伟大的问题。我不能留下评论,所以我在这里回复。

Perhaps one of these will work for you.

也许其中一个对你有用。

ActiveSheet.Shapes.Delete
ActiveSheet.DrawingObjects.Delete
ActiveSheet.Pictures.Delete