Add worksheet with 'microsoft​.office.in​terop.exce​l'

5 ビュー (過去 30 日間)
Aleksejs
Aleksejs 2011 年 8 月 12 日
回答済み: Scott 2015 年 6 月 26 日
Guys,
saw some suggestions on how to add sheets when using actxserver('excel.application'). But am instead trying to cope with .Net ... Does anyone know how to add worksheets in my case?
NET.addAssembly('microsoft.office.interop.excel');
app = Microsoft.Office.Interop.Excel.ApplicationClass;
books = app.Workbooks;
newWB = books.Add;
app.Visible = true;
b = 4;
for i = 1:b
sheets = newWB.Worksheets;
if i > 3
% ??? Microsoft.Office.Interop.Excel.Worksheets.Add([],sheets.Item(3));
end
newSheet = sheets.Item(i);
newWS = Microsoft.Office.Interop.Excel.Worksheet(newSheet);
end
Thanks, Aleks

回答 (1 件)

Scott
Scott 2015 年 6 月 26 日
This worked for me
self.hCurrentSheet = Microsoft.Office.Interop.Excel.Worksheet(self.hWorkbook.Worksheets.Add());

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by