Free Support Forum - aspose.com

Colour for particular cell

Hi,

This is seshadri.I want to put different colour for cell which contain formulae.

can you please tell me the solution.

thanks and regards,

seshadri.

Hi Seshadri,

May the following sample code help you for your need, kindly consult it:

private void Page_Load(object sender, System.EventArgs e)
{

// Creates a sheets object.
WebWorksheets sheets = GridWeb1.WebWorksheets;
// Creates a cells object with reference to first sheet 's cells.
WebCells cells = sheets[0].Cells;
WebCell cell = cells["A1"];
// Implements a formula on it.
cell.Formula = "=B1+C1";
cell = cells["A2"];
//Implements a formula on it.
cell.Formula = "=A1+C2";
GridWeb1.WebWorksheets[0].Cells["B1"].PutValue(1);
GridWeb1.WebWorksheets[0].Cells["C1"].PutValue(3);
GridWeb1.WebWorksheets[0].Cells["C2"].PutValue(2);

foreach (WebCell cell1 in sheets[0].Cells)
{

if(cell1.Formula != null)
{
cell1.Style.BackColor = Color.Red;

}
}

// Put user code to initialize the page here
}

Thank you.