how can we read excel file with cells colors, format and having image?

21 views (last 30 days)
azizullah khan
azizullah khan on 8 Sep 2014
Edited: Joseph Cheng on 8 Sep 2014
Want to read excel file with cells colors and with cell format (formulas etc) and the excel file also contain images.Kindly share your experience with me.I tried a lot but doesn't succeed.Thanks.
azizullah khan
azizullah khan on 8 Sep 2014
Just make an experience with that..If you have any idea share it with me...Thanks for comment.

Sign in to comment.

Answers (1)

Joseph Cheng
Joseph Cheng on 8 Sep 2014
Edited: Joseph Cheng on 8 Sep 2014
So i try not to do this and live in one world but these things can be achieved through the ActiveX server.
Say for instance i create a simple excel file called testxlsx.xlsx. column A is just the number 1 through 10. Column B is 2*Column A, Column C is 3*Column A -3, etc. where Column A is a constant and B onward is formula. Then color pattern it with something.
Now if you go.
xl = actxserver('excel.application'); %open activex server
xl.visible = 1; %make things visible
wb = xl.Workbooks.Open('C:\temps\testxlsx.xlsx'); %open specified xlsx file
wbSheet1 = wb.Sheets.Item('Sheet1'); %specify sheet
robj = wbSheet1.Columns.End(4); % Find the end of the column
numrows = robj.row; % And determine what row it is
dat_range = ['C1']; % Read any cell
rngObj = wbSheet1.Range(dat_range); %set that as active cell(s)
get(rngObj.interior) %get interior values. %see that color is dec value. convert to hex and see it as the #FFFFFF type of color.
CellObj = get(rngObj);
Then if you peek inside CellObj for the line above you'll see that the excel formula is stored in
Formula: '=B1*3-A1'
FormulaArray: '=B1*3-A1'
FormulaHidden: 0
FormulaLocal: '=B1*3-A1'
FormulaR1C1: '=RC[-1]*3-RC[-2]'
FormulaR1C1Local: '=RC[-1]*3-RC[-2]'
I do not know how to mass do this without going cell by cell and extracting the data.
oh and finding + extracting the plots is something i never figured out where that is located.

Community Treasure Hunt

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

Start Hunting!