How to set Tab color of an excel sheet using Matlab command?

3 ビュー (過去 30 日間)
vinvino
vinvino 2018 年 7 月 6 日
回答済み: vinvino 2018 年 7 月 9 日
I would like to color the spreadsheet tab into 'RED' or 'Green' using Matlab command.
Thanks in advance!!

採用された回答

vinvino
vinvino 2018 年 7 月 9 日
The below command i used and it worked for me
% Excel = actxserver('excel.application');
WB = Excel.Workbooks.Open(fullfile('Sample.xls'));
% Set the color of Sheet 1 to RED
%'Red'--> give the proper color index ex: Red = 3
%'SheetNo'--> ex: Sheetno = 1
WB.Worksheets.Item(SheetNo).Tab.ColorIndex = Red;

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 7 月 6 日
Can you even do it in Excel? I've never done it. But if you can, just record a macro in Excel to do it, then transfer the commands to an ActiveX object in MATLAB if you're using Windows.
ActiveX demo attached.
  1 件のコメント
vinvino
vinvino 2018 年 7 月 9 日
編集済み: vinvino 2018 年 7 月 9 日
Hi Image Analst,
yes i got the solution. Thanks for the ExcelDemo.m file where i got more info. The below command i used and it worked for me
Excel = actxserver('excel.application');
WB = Excel.Workbooks.Open(fullfile('Sample.xls'));
% Set the color of Sheet 1 to RED
%'Red'--> give the proper color index ex: Red = 3
%'SheetNo'--> ex: Sheetno = 1
WB.Worksheets.Item(SheetNo).Tab.ColorIndex = Red;

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

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by