How to set Excel cell color to from Matlab using R1C1 range notation?

5 次查看(过去 30 天)
This question is related to this one:
https://www.mathworks.com/matlabcentral/answers/3352-how-to-set-excel-cell-color-to-red-from-matlab
And the question is, can the Range be specifed in R1C1 notation rather than A1 notation? And if so, how?
WB.Worksheets.Item(1).Range('A1').Interior.ColorIndex = 3;
I have tried the following with no success:
WB.Worksheets.Item(1).Range(cells(i+1,j+1),cells(i+1,j+1)).Interior.ColorIndex = str2double(outTblColor{i,j});
Thanks for the help.
  2 个评论
Allen
Allen 2020-1-29
As alternative to trying to work with R1C1 notation (never was successful using this via ActiveX), you could use the xlscol function (FileExchange) to convert R1C1 input to the standard A1 notation.
The following code segment shows one way of converting your i and j variables to row and columns text, respectively.
A1notation = sprintf('%s%s',xlscol(j),i+48); % Adding 48 to i corrects for ASCII values of numeric characters.
Don Kalinich
Don Kalinich 2020-1-29
Thanks! Writing something like xlscol was going to be my next step. I implemented Mr. Crosby's xlscol and it works like charm.

请先登录,再进行评论。

回答(0 个)

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by