matlab中如何将已经写入信息的excel表的指定部分清空,然后再写入新的内容?

 我来答
nweibd
2011-05-07 · TA获得超过394个赞
知道小有建树答主
回答量:533
采纳率:54%
帮助的人:209万
展开全部
请参阅MATLAB的帮助中的Compont Object Model and ActiveX部分的相关文档即可!
追问
能不能给详细的一个例子啊?
追答
帮助中有例子!
exl = actxserver('excel.application');

The ActiveX object that is returned provides access to a number of interfaces supported by the Excel program. Use the workbook interface to open the Excel file containing the data.

exlWkbk = exl.Workbooks;
exlFile = exlWkbk.Open([docroot '/techdoc/matlab_external/examples/input_resp_data.xls']);

Use the workbook's sheet interface to access the data from a range object, which stores a reference to a range of data from the specified sheet. This example accesses all the data in column A, first cell to column G, last cell:

exlSheet1 = exlFile.Sheets.Item('Sheet1');
robj = exlSheet1.Columns.End(4); % Find the end of the column
numrows = robj.row; % And determine what row it is
dat_range = ['A1:G' num2str(numrows)]; % Read to the last row
rngObj = exlSheet1.Range(dat_range);

At this point, the entire data set from the Excel file's sheet1 is accessed via the range object interface. This object returns the data in a MATLAB cell array, which can contain both numeric and character data:

exlData = rngObj.Value;

exl2 = actxserver('excel.application');
exlWkbk2 = exl2.Workbooks;
wb = invoke(exlWkbk2,'Add');
graphSheet = invoke(wb.Sheets,'Add');
Shapes = graphSheet.Shapes;

The following code implements the Save Graph button callback:

function saveButtonCallback(src,evt)
tempfig = figure('Visible','off','PaperPositionMode','auto');
tempfigfile = [tempname '.png'];
ah = findobj(f,'type','axes');
copyobj(ah,tempfig) % Copy both graph axes and legend axes
print(tempfig,'-dpng',tempfigfile);
Shapes.AddPicture(tempfigfile,0,1,50,18,300,235);
exl2.visible = 1;
end
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式