change excel spreadsheet color when exporting data

8 ビュー (過去 30 日間)
Marco
Marco 2014 年 7 月 18 日
コメント済み: KRUNAL 2014 年 8 月 5 日
Hi
When I'm writing data out to excel, I would like to color code cells with values less than 0.0. I'm currently using xlswrite
xlswrite(xlsfile,[header; output],sheetText,'A2');
where header is the column header for the data, and output is the numeric data being exported. I'm usually working with data sized 100 rows by 15 column.
I was wondering if there was a way to look and loop inside excel, find a negative number, highlight it red and loop to the next... Thanks

回答 (3 件)

KRUNAL
KRUNAL 2014 年 7 月 29 日
Hey, even I am also facing the same issue. However after observing the 1st link you have posted I think you can do something like this:
%eg check the numbers that are greater than 100 in each row/column and should print 'bigger'(text1) in cells where you get num > 100 else print smaller(text2) %%
if num > 100
%whatever you want to output say any "text" %
xlsfont(filename,sheetname,'Find',text1, color,color index number1)
else
xlsfont(filename,sheetname,'Find',text2, color,color index number2)
end
Is this something you are trying to do? If so I would suggest you should try it,if you haven't tried it yet

KRUNAL
KRUNAL 2014 年 8 月 1 日
編集済み: KRUNAL 2014 年 8 月 1 日
I tried what I had asked you to do. However for me there was unusual thing that is happening. After reading all data, it does change color of the cell but it does only for the text that it gets for the 1st time out of the 10-12 cells containing the same text. Rest all are remaining the same and this happens in all the sheets of that excel file(I have 5-6 sheets in 1 excel file).What about you?

Image Analyst
Image Analyst 2014 年 8 月 1 日
Sure, you can do it. Either find out the cell addresses before you throw the data in there, or scan it afterwards. Either way you'll have to use ActiveX. Will you be willing to use ActiveX? You can use xlsfont but you'll have to modify it so that it doesn't launch and shutdown Excel every time you call it or else it will take an eternity to modify a bunch of cells.
  10 件のコメント
KRUNAL
KRUNAL 2014 年 8 月 4 日
Thank you. i will try to understand this file and based on it will try to create my own file from it. If required,will post questions on it here.
KRUNAL
KRUNAL 2014 年 8 月 5 日
I tried running the 1st part.It basically creates a new excel file and then throws the error of file open and existing

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by