MATLAB: Is it possible to detect color of sheet tab with actxserver

color spreadsheetMATLABsheet labelsheetname color

I have got excel data files and would like to read data only from the spreadsheets having Green color. So in total i would be having data from only Green labelled spreadsheets from all the excel files.

Best Answer

I'd use Tab.Color instead of Tab.ColorIndex otherwise you'd also have to query the actual palette used by excel.
Completely untested code written on the fly, there may be typos / mistakes. Use MSDN to check the syntax of excel methods.
filepath = 'C:\somewhere\somefile.xlsx';
excel = actxserver('Excel.Application');
workbook = excel.Workbooks.Open(filepath);
numsheet = worbook.Worksheets.Count;
namergb = cell(numsheet, 2);
for sheetidx = 1:numsheet
sheet = workbook.Worksheets.Item(sheetidx)
namergb{sheetidx, 1} = sheet.Name;
bgr = sheet.Tab.Color;
namergb{sheetidx, 2} = uint8([mod(bgr, 256), floor(mod(bgr/256, 256)), floor(bgr/65536)]);
end
workbook.Close;
excel.Quit;
cell2table(namergb, 'VariableNames', {'SheetName', 'RGB'})