Skip to main content
A newer version of this page is available. .

IXlCell.Formatting Property

Gets or sets cell format characteristics.

Namespace: DevExpress.Export.Xl

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

Declaration

XlCellFormatting Formatting { get; set; }

Property Value

Type Description
XlCellFormatting

An XlCellFormatting object that specifies format characteristics applied to the cell.

Remarks

The XlCellFormatting object provides a set of properties and methods to change cell format settings.

For more information on how to format cells in a worksheet, see the How to: Format a Cell document and the Formatting section of examples.

Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/xl-export-api-examples-t253492

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

    // Create six successive columns and set their widths.
    for(int i = 0; i < 6; i++) {
        using(IXlColumn column = sheet.CreateColumn()) {
            column.WidthInPixels = 100;
        }
    }

    // Specify the "Good, Bad and Neutral" formatting category.
    using(IXlRow row = sheet.CreateRow()) {
        using(IXlCell cell = row.CreateCell()) {
            cell.Value = "Good, Bad and Neutral";
        }
    }
    using(IXlRow row = sheet.CreateRow()) {
        // Create a cell with the default "Normal" formatting.
        using(IXlCell cell = row.CreateCell()) {
            cell.Value = "Normal";
        }
        // Create a cell and apply the "Bad" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Bad";
            cell.Formatting = XlCellFormatting.Bad;
        }
        // Create a cell and apply the "Good" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Good";
            cell.Formatting = XlCellFormatting.Good;
        }
        // Create a cell and apply the "Neutral" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Neutral";
            cell.Formatting = XlCellFormatting.Neutral;
        }
    }

    sheet.SkipRows(1);

    // Specify the "Data and Model" formatting category.
    using(IXlRow row = sheet.CreateRow()) {
        using(IXlCell cell = row.CreateCell()) {
            cell.Value = "Data and Model";
        }
    }
    using(IXlRow row = sheet.CreateRow()) {
        // Create a cell and apply the "Calculation" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Calculation";
            cell.Formatting = XlCellFormatting.Calculation;
        }
        // Create a cell and apply the "Check Cell" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Check Cell";
            cell.Formatting = XlCellFormatting.CheckCell;
        }
        // Create a cell and apply the "Explanatory..." predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Explanatory";
            cell.Formatting = XlCellFormatting.Explanatory;
        }
        // Create a cell and apply the "Input" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Input";
            cell.Formatting = XlCellFormatting.Input;
        }
        // Create a cell and apply the "Linked Cell" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Linked Cell";
            cell.Formatting = XlCellFormatting.LinkedCell;
        }
        // Create a cell and apply the "Note" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Note";
            cell.Formatting = XlCellFormatting.Note;
        }
    }
    using(IXlRow row = sheet.CreateRow()) {
        // Create a cell and apply the "Output" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Output";
            cell.Formatting = XlCellFormatting.Output;
        }
        // Create a cell and apply the "Warning Text" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Warning Text";
            cell.Formatting = XlCellFormatting.WarningText;
        }
    }

    sheet.SkipRows(1);

    // Specify the "Titles and Headings" formatting category.
    using(IXlRow row = sheet.CreateRow()) {
        using(IXlCell cell = row.CreateCell()) {
            cell.Value = "Titles and Headings";
        }
    }
    using(IXlRow row = sheet.CreateRow()) {
        // Create a cell and apply the "Heading 1" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Heading 1";
            cell.Formatting = XlCellFormatting.Heading1;
        }
        // Create a cell and apply the "Heading 2" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Heading 2";
            cell.Formatting = XlCellFormatting.Heading2;
        }
        // Create a cell and apply the "Heading 3" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Heading 3";
            cell.Formatting = XlCellFormatting.Heading3;
        }
        // Create a cell and apply the "Heading 4" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Heading 4";
            cell.Formatting = XlCellFormatting.Heading4;
        }
        // Create a cell and apply the "Title" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Title";
            cell.Formatting = XlCellFormatting.Title;
        }
        // Create a cell and apply the "Total" predefined formatting to it.
        using (IXlCell cell = row.CreateCell()) {
            cell.Value = "Total";
            cell.Formatting = XlCellFormatting.Total;
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Formatting property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also