Set Excel cell interior color to RGB value
Mostrar comentarios más antiguos
Hi,
In matlab I read a .BMP file of 20x20x3. Now I want to set the cell color of A1 of my workbook.xlsx, to the color of the first pixel.
% open image
a=imread('image1','bmp');
% Connect to Excel
Excel = actxserver('excel.application');
% Get Workbook object
WB = Excel.Workbooks.Open(fullfile(pwd, 'workbook1.xlsx'),0,false);
% Set the color of cell "A1" of Sheet 1 to RGB
WB.Worksheets.Item(1).Range('A2').Interior.Color = RGB(a(1,1,1),a(1,1,2),a(1,1,3));
% Save Workbook
WB.Save();
% Close Workbook
WB.Close();
% Quit Excel
Excel.Quit();
Well, this doesnt work. It works with interior.color = hex2dec('00FF00')
but not with RGB. How can I make this work? Error I get is: Undefined function or method 'RGB' for input arguments of type 'uint8'
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!