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

조회 수: 10 (최근 30일)
azizullah khan
azizullah khan 2014년 9월 8일
편집: Joseph Cheng 2014년 9월 8일
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.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by