How to insert multiple spreadsheets to a workbook from Matlab

Matlab provide a method to insert one spreadsheet: using the command
eNewSheet = Add(eSheets,[],eSheet1);
However, if I know I need to add multiple spreadsheets, e.g. 5, is there a way to tell Add comment, or I have to do a for loop to insert 5 sheets?
Thanks

 採用された回答

Michael Croucher
Michael Croucher 2020 年 9 月 28 日

0 投票

You can add the number of sheets as an extra argument. So, for 5 sheets:
eNewSheet = Add(eSheets,[],eSheet1,5);

1 件のコメント

wangm
wangm 2020 年 9 月 28 日
編集済み: Walter Roberson 2020 年 9 月 28 日
Thanks Michael. It works.
I also tried to test if I can add spreadsheet before using the method provided in Matlab, i got error. Have you got the same error. here is the link Matlab provided:
I followed the exact commend:
e = actxserver('Excel.Application');
Add(e.Workbooks);
e.Visible = 1;
eSheets = e.ActiveWorkbook.Sheets;
eSheet1 = Item(eSheets,1);
eNewSheet = Add(eSheets,[],eSheet1);
It works if I want to add sheet after the first. But if I want to add sheet before the first sheet by typing
eNewSheet = Add([], eSheets,eSheet1);
I got error: Undefined command/function 'Add'.
How do you interpolate the explanation:
To call Add with the After argument, omit the first argument, Before, by using an empty array [] in its place.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2011b

タグ

質問済み:

2020 年 7 月 29 日

編集済み:

2020 年 9 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by