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
2014-9-8
Azizullah - why is getting the cell colour and format important? What are you trying to do with this information?
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!