Wednesday, 05 January 2011 07:49

Excel Cell Fill- Set Cell Fill in Excel with C#, VB.NET

Written by  Administrator
Rate this item
(0 votes)
Cell Fill is one kind of cell format settings in Excel, which includes cell background color and pattern style. With cell fill, the appearance of Excel file can be beautified. Also, data in cell which is set background color or pattern style can be more obvious.


Spire.XLS for .NET, a professional .NET Excel component on manipulating Excel files, enables users to set in Excel. And this guide will focuses on how to realize Excel cell fill in C#, VB.NET, including cell background color and pattern style settings. User can set style property of CellRange class which Spire.XLS for .NET provides to get wanted background color and pattern style of one specified cell or a cell range. The following screenshot shows the result- workbook without cell fill setting.


Add Excel Cell Fill


Download and install Spire.XLS for .NET and use the following code to set cell fill.

Sample Code for Setting Cell Fill in Excel with C#, VB.NET

   worksheet.Range["A7:F7"].Style.Color = Color.Yellow;
   worksheet.Range["A8:F8"].Style.FillPattern = ExcelPatternType.Percent125Gray;

  worksheet.Range("A7:F7").Style.Color = Color.Yellow
  worksheet.Range("A8:F8").Style.FillPattern = ExcelPatternType.Percent125Gray



Spire.XLS is a professional .NET Excel component which enables developers/programmers to fast generate, read, write and modify Excel document for .NET and Silverlight. More about this .NET Excel Component.

Additional Info

  • tutorial_title: Set Cell Fill in Excel
Last modified on Wednesday, 08 January 2014 02:44