I added only the relevant lines of my code:
asume I have RGB of [106 113 50]. I want to color the cells A1 till A7 by its color.
In excel I got a different color than mspaint(some site brought me the same color of mspaint)
this is my code:
rgb = [106 113 50];
clr = rgb * [1 256 256^2]'; %# convert to long number Excel understands
e = actxserver ('Excel.Application'); %# open Activex server
filename = fullfile(path_of_file,name_of_file); %# full path required
ewb = e.Workbooks.Open(filename); %# open the file
esh = ewb.ActiveSheet;
esh.Range('A1:A7').Interior.Color = clr;
I cant see from the picture which version of Excel it is. If its below 2007 then Excel only supports something like 56 colours so maps to the nearest one of them Regardless of whats in your code