MATLAB: Changing the name of the sheet in excel

changing sheet name in excel

I want to change the names of sheets in excel and then i need to perform the write operation on those sheets?
Is it possible to do with xlswrite?

Best Answer

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.