Free Support Forum - aspose.com

Solid Style Background Color not appearing on Cell

I can’t seem to set a solid background color on a cell with Aspose Cells v3.9.0.1. The following code is used to attempt to set the background color.

using System.Drawing;
using NUnit.Framework;

namespace Aspose.Cells.Test
{
[TestFixture]
public class Class1
{
[Test]
public void SetBackgroundColor()
{
License license = new License();
license.SetLicense(@“C:\AtlasAssembly\Aspose.Excel.lic”);

		Workbook workBook = new Workbook();
		workBook.Worksheets.Add();
		
		workBook.Worksheets[0].Cells["F5"].Style.BackgroundColor = Color.Yellow;
		workBook.Worksheets[0].Cells["F5"].Style.Pattern = BackgroundType.Solid;
		
		workBook.Save(@"C:\Documents and Settings\t-joelb\Desktop\TestOutput.xls", FileFormatType.SpreadsheetML);
	}
}

}

Attached is a picture of the result of this code when opened in Excel. Thanks for all your help.

-- Joel

Hi Joel,

Please check http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/BackgroundPattern.html .

If pattern is solid, you should set foreground color:

workBook.Worksheets[0].Cells["F5"].Style.ForegroundColor = Color.Yellow;
workBook.Worksheets[0].Cells["F5"].Style.Pattern = BackgroundType.Solid;