How can I add a Header or a Footer to an EXCEL worksheet using MATLAB 7.7 (R2008b)?
4 ビュー (過去 30 日間)
古いコメントを表示
I am writing results to an EXCEL file using the XLSWRITE command. I currently have to manually add an EXCEL header/footer using View - > Header/Footer pull down menu items for each data worksheet. Using MATLAB, I am unable to programmatically write a Header/Footer for the worksheet I create.
採用された回答
MathWorks Support Team
2009 年 6 月 27 日
The ability to programmatically add the Header and Footer to an Excel worksheet can be implemented in MATLAB using the COM interface.
The ACTXSERVER command can be used to create a COM server running Microsoft Excel. You can then add the Header and Footer using the different methods for the workbook and then call XLSWRITE to write the data to the Excel worksheet as follows:
a = actxserver('Excel.Application');
a.Visible =1;
a.Workbooks.Add;
a.activeWorkbook.activesheet.PageSetup.LeftFooter = 'MyFooter';
a.activeWorkbook.activesheet.PageSetup.LeftHeader = 'MyHeader';
a.activeWorkbook.SaveAs('test.xlsx');
a.activeWorkbook.Close;
xlswrite('test.xlsx',[1 2 3]);
The following options can also be modified in a similar way:
a.activeWorkbook.activeWorksheet.PageSetup.CenterHeader
a.activeWorkbook.activeWorksheet.PageSetup.RightHeader
a.activeWorkbook.activeWorksheet.PageSetup.CenterFooter
a.activeWorkbook.activeWorksheet.PageSetup.RightFooter
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!