2.2.3.34 wcellcolor

Brief Information

Set fill or font color for worksheet cells

Command Line Usage

1. wcellcolor 1[1]:2[3] color(red); // active sheet col(1) row(1) to col(2) row(3) set to red
2. wcellcolor 2 color(blue); // whole col(2) set to blue
3. wcellcolor 3 color(red) type:=font; // whole col(3) set font color to red
4. wcellcolor i:=[Book1]Sheet1!col(B)[2] c:=color(127,255,127); //set to specific RGB

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input irng

Input

Range

<active>
Specify cell range to fill
Color color

Input

int

0
Specify the color. Color index from 0 (Black). You can also select color from Fill Color drop-down list on the Style tool bar.
Type type

Input

int

fill
Set the selected cells color to Fill Color or the selected font color to Font Color.

Option list:

  • fill:Fill Color
Fill the cell color
  • font:Font Color
Change the select font color
Undo undo

Input

int

0
Specify whether can undo the operation

Description

This function is used to set cell(s) color to fill color or set the selected font color to Font color.

Examples

  • Sample-1
// create new book with some columns and fill with random data
newbook;
newsheet cols:=6 xy:="Y";
loop(i,1,6){wcol(i)=normal(100)};
// select all cells with value greater than or equal to 0.5 and color them
wcellsel 1:end c:=ge v:=0.5;
wcellcolor c:=color(green);
wcellcolor c:=color(red) type:=1;
wcellsel; // this deselects cells so colors show
  • Sample-2
/*
This example shows how to perform linear regression by scripts, detact the outliers and label these cells.
The sample data is exe_path\Samples\Curve Fitting\Outlier.dat
1. Load raw data.
2. Perform linear regression by xop mechanism
3. Identify outliers by standardized residuals.
4. Set outliers' cell color in raw worksheet as red.
*/
// Import sample data
fname$ = system.path.program$ + "Samples\Curve Fitting\Outlier.dat";
newbook;
impASC;
// Perform linear regression by xop
xop e:=init c:=FitLinear i:=lrGUI;
lrGUI.GUI.InputData.Range1.X$=Col(A);
lrGUI.GUI.InputData.Range1.Y$=Col(B);
// Output standardized residual data
lrGUI.GUI.ResAnalysis.Stad = 1;
// generate a linear fit report with the prepared GUI tree
type -mb 0;
xop e:=report i:=lrGUI; 
type -mb -1;
//Clean up operation objects after fit
xop e:=cleanup;
// Get output report tree
getresults tr Fitlinear1!;
range residual = FitLinearCurve1!col(5);
range rawdata = Outlier!Col(2);

// Set raw data cell color as red if residual > 2.5*sigma
for(ii = 1; ii <= tr.RegStats.C1.N; ii++)
{
	if( abs(residual[ii]) > 2.5) 
	{
		wcellcolor rawdata[ii] color:=2; 
	}
}

// Active source worksheet
page.active = 1;