フィルターのクリア

Add a new Excel sheet from Matlab

107 ビュー (過去 30 日間)
Derek Jing
Derek Jing 2011 年 3 月 6 日
コメント済み: pravesh verma 2016 年 7 月 7 日
Hi,
I am using ActiveX server to control Excel spreadsheet. Now I am using Worksheet.Sheets.Add to add a new sheet, but it add before the currently active sheet. I do not know how to apply the 'After' option there.
In all, I want to add a new sheet to the end (the last sheet), and set a new for this new sheet. Anyone can tell me how to apply 'After' and 'name' options to the Matlab command?
Thanks in advance for your help.
Regards, Derek
  1 件のコメント
pravesh verma
pravesh verma 2016 年 7 月 7 日
sir plz provide all matlab sheet

サインインしてコメントする。

採用された回答

Jiro Doke
Jiro Doke 2011 年 3 月 6 日
According to the VBA documentation on MSDN, to add after the active sheet, specify the active sheet as the second argument to the Add method:
Worksheet.Sheets.Add([], ActiveSheet)
Here's an example that adds a new sheet after the last worksheet (example assumes an Excel file called "Book1.xlsx" in the current folder):
% Connect to Excel
Excel = actxserver('excel.application');
% Get Workbook object
WB = Excel.Workbooks.Open(fullfile(pwd, 'Book1.xlsx'), 0, false);
% Get Worksheets object
WS = WB.Worksheets;
% Add after the last sheet
WS.Add([], WS.Item(WS.Count));
% Save
WB.Save();
% Quit Excel
Excel.Quit();
  4 件のコメント
Ilyas
Ilyas 2014 年 10 月 21 日
Wouldn't it be much easier if you provided a simple code? I don't understand what you are trying to do.
Image Analyst
Image Analyst 2014 年 10 月 21 日
Ilays, it IS simple. There are only 5 lines of code there. The rest is just comments to explain it.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by