2013-08-01 71 views
1

參考我以前的問題(add sparklines to excel with matlab),我可以設法創建迷你圖線,但我無法弄清楚如何以綠色/紅色着色高點/低點。我想:通過MATLAB的sparkline excel繪圖中的顏色高點/低點

% Open new workbook 
excel   = actxserver('excel.application'); 
excel.visible = 1; 
wrkbook  = excel.Workbooks.Add(); 
sheet   = wrkbook.Sheets.Item(1); 

% Write some data 
sheet.Range('B1:Z1').Value = rand(1,25); 

% Add column sparklines to 'A1', type 'xlSparkColumn' and DataSource: 'B1:Z1' 
excel.ReferenceStyle = 'xlA1'; 
s = sheet.Range('A1').SparklineGroups.Add('xlSparkColumn','B1:Z1'); 

% Color 
s.Point.Highpoint.Color.Color = 4697456; 
s.Point.Lowpoint.Color.Color = 255; 

也可參閱setting custom cell background color

回答

1

試試這個參考:

% set highpoint color to red (color format is BGR) 
s.Points.Highpoint.Color.Color = hex2dec('0000FF'); 

% make it visible 
s.Points.Highpoint.Visible = true; 

sparklines

+0

感謝'。可見= TRUE;。我很匆忙,但一旦我有時間,我一定會檢查你以前的工具鏈接。 – Oleg