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

3 次查看(过去 30 天)
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.
  2 个评论
Geoff Hayes
Geoff Hayes 2014-9-8
Azizullah - why is getting the cell colour and format important? What are you trying to do with this information?
azizullah khan
azizullah khan 2014-9-8
Just make an experience with that..If you have any idea share it with me...Thanks for comment.

请先登录,再进行评论。

回答(1 个)

Joseph Cheng
Joseph Cheng 2014-9-8
编辑:Joseph Cheng 2014-9-8
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!

Translated by