Font color from Excel to Matlab

조회 수: 2 (최근 30일)
Helma Maria Tróndheim
Helma Maria Tróndheim 2017년 10월 6일
댓글: Helma Maria Tróndheim 2017년 10월 12일
Hi,
I've to import a lot (four years logged every minute for 60 objects) of logged data from Excel into Matlab. If the logger wasn't working properly during a measurement the data in Excel is coloured red. Is there any way I can get the color of the data in Excel to Matlab so I can sort the data that wasn't measured properly?

채택된 답변

ES
ES 2017년 10월 6일
편집: ES 2017년 10월 6일
objExcel=actxserver('excel.application');
objExcelW=objExcel.Workbooks;
objExcelF=objExcelW.Open('ExcelFileName');
objExcelS=objExcelF.ActiveSheet;
colour = objExcelS.Range('A1').Interior.color; %To read the colour of A1 cell
objExcelF.Close;
objExcel.Quit;
objExcel.delete;
You can read the colour value and split the colours
[R, G, B] to hex is R*256*256+G*256+B where R, G, B can be (0 to 255)
  댓글 수: 1
Helma Maria Tróndheim
Helma Maria Tróndheim 2017년 10월 12일
Thank you, but I wanted the font color, so I changed it to:
colour = objExcelS.Range('A1').Font.color;
This worked

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

ES
ES 2017년 10월 6일
It is not straighforward. You will have to use ActiveX https://in.mathworks.com/help/matlab/matlab_external/using-a-matlab-application-as-an-automation-client.html

카테고리

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