在Matlab中重命名Excel工作表名称 [英] Renaming an Excel Sheet Name in Matlab
本文介绍了在Matlab中重命名Excel工作表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
可以直接使用ActiveX MATLAB:
xlswrite('test.xls',1)%#创建测试文件
e = actxserver( 'Excel.Application'); %#打开ActiveX服务器
ewb = e.Workbooks.Open('c:\test\test.xls'); %#打开文件(输入完整路径!)
ewb.Worksheets.Item(1).Name ='new name'; %#rename第一张
ewb.Save%#保存到同一个文件
ewb.Close(false)
e.Quit
测试时要小心,覆盖原始文件。备份。
I am creating an Excel using the Matlab xlswrite function. How can I change the name of the first sheet of this Excel document? (I have read the official matlab help, but I haven´t found any solution).
解决方案
You can use ActiveX directly from MATLAB:
xlswrite('test.xls',1) % # create test file
e = actxserver('Excel.Application'); % # open Activex server
ewb = e.Workbooks.Open('c:\test\test.xls'); % # open file (enter full path!)
ewb.Worksheets.Item(1).Name = 'new name'; % # rename 1st sheet
ewb.Save % # save to the same file
ewb.Close(false)
e.Quit
Be careful while testing, it overwrite the original file. Make a backup.
这篇关于在Matlab中重命名Excel工作表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文