reading color information from multiple xls cells
3 views (last 30 days)
Show older comments
Hi,
i'm trying to read the Interior.ColorIndex value for multiple cells at once.
it works for 1 cell, but not a range of cells. Any idea how to make this work for more that 1 cell?
handles.ExFileName='r:\Magview\source\data\points.xlsx';
h = actxserver('Excel.Application');
workbook = h.Workbooks.Open(handles.ExFileName);
Sheets = h.ActiveWorkBook.Sheets;
Sheets.Item(1).Activate;
c = h.Range('A1').Interior.ColorIndex % returns 47
c2 = h.Range('A1:A500').Interior.ColorIndex % returns a single NaN
invoke(h, 'Quit');
delete(h)
0 Comments
Answers (1)
Walter Roberson
on 15 Feb 2022
https://www.mathworks.com/matlabcentral/answers/1622010-how-do-i-select-several-rows-in-excel#answer_868620 shows how to create a union of ranges.
3 Comments
Image Analyst
on 15 Feb 2022
Since a range of cells could be shaded a range of different colors, what do you expect it to return? I suspect there is not API function to handle that and you'll have to process your cells one cell at a time to get each color in turn.
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!