XlFormatting.Fill Property

Gets or sets fill settings to be applied to the cell background.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.1.Core.dll


public XlFill Fill { get; set; }

Property Value

Type Description

An XlFill object that specifies cell background characteristics.


To change the cell background color, use the Fill property of the XlCellFormatting object, which controls the format settings of worksheet cells. The XlFill object provides static methods you can use to fill cells with solid colors (XlFill.SolidFill), or shade cells with patterns (XlFill.PatternFill).

To apply fill settings to a cell, assign the specified XlCellFormatting instance to the IXlCell.Formatting property or pass it to the IXlCell.ApplyFormatting method as a parameter, as shown in the example below. Note that the XlCellFormatting object supports implicit conversion from the XlFill object, so that you can directly apply background settings to a cell without using unnecessary cast operators. For more information on how to fill a cell background, refer to the How to: Change Cell Background Color topic.


// Create a new document and begin to write it to the specified stream. 
using (IXlDocument document = exporter.CreateDocument(stream)) {

    // Specify formatting settings to be applied to document content.
    XlCellFormatting formatting = new XlCellFormatting();

    // Specify cell background color.
    formatting.Fill = XlFill.SolidFill(XlColor.FromArgb(0xCE, 0x8B, 0xDA));

    // Specify font settings (font name, color, size and style).
    formatting.Font = new XlFont();
    formatting.Font.Name = "MV Boli";
    formatting.Font.SchemeStyle = XlFontSchemeStyles.None;
    formatting.Font.Size = 16;
    formatting.Font.Color = Color.Wheat;
    formatting.Font.Bold = true;

    // Specify the alignment of cell content.
    formatting.Alignment = XlCellAlignment.FromHV(XlHorizontalAlignment.Center, XlVerticalAlignment.Center);

    // Specify outside border settings.
    formatting.Border = XlBorder.OutlineBorders(XlColor.FromArgb(0x47, 0x7B, 0xD1), XlBorderLineStyle.Thick);

    // Create a new worksheet. 
    using (IXlSheet sheet = document.CreateSheet()) {

        // Create the first column and set its width.
        using (IXlColumn column = sheet.CreateColumn())
            column.WidthInPixels = 180;

        // Create the first row in the worksheet.
        using (IXlRow row = sheet.CreateRow()){
            // Create a cell and specify its format settings.
            using (IXlCell cell = row.CreateCell())
                cell.Value = "Custom Format";
See Also