corelibraries-devexpress-dot-export-dot-xl-a46ce088.md
Represents the object that specifies cell format characteristics.
Namespace : DevExpress.Export.Xl
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public class XlCellFormatting :
XlFormatting,
ISupportsCopyFrom<XlCellFormatting>
Public Class XlCellFormatting
Inherits XlFormatting
Implements ISupportsCopyFrom(Of XlCellFormatting)
The following members return XlCellFormatting objects:
Show 25 links
The XlCellFormatting object provides a set of properties and methods you can use to change cell format settings.
Predefined formatting
Themed formatting
Custom formatting
To apply the specified format options to a cell, pass the corresponding XlCellFormatting object to the IXlCell.ApplyFormatting method as a parameter, or assign it to the IXlCell.Formatting property. Note that you can also share format settings with multiple cells in a row at once by utilizing the IXlRow.BlankCells and IXlRow.BulkCells methods.
To format the entire row or column, use the IXlRow.ApplyFormatting and IXlColumn.ApplyFormatting methods, or IXlRow.Formatting and IXlColumn.Formatting properties, respectively.
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.
// 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";
cell.ApplyFormatting(formatting);
}
}
}
}
' Create a new document and begin to write it to the specified stream.
Using document As IXlDocument = exporter.CreateDocument(stream)
' Specify formatting settings to be applied to document content.
Dim formatting As New XlCellFormatting()
' Specify cell background color.
formatting.Fill = XlFill.SolidFill(XlColor.FromArgb(&HCE, &H8B, &HDA))
' 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(&H47, &H7B, &HD1), XlBorderLineStyle.Thick)
' Create a new worksheet.
Using sheet As IXlSheet = document.CreateSheet()
' Create the first column and set its width.
Using column As IXlColumn = sheet.CreateColumn()
column.WidthInPixels = 180
End Using
' Create the first row in the worksheet.
Using row As IXlRow = sheet.CreateRow()
' Create a cell and specify its format settings.
Using cell As IXlCell = row.CreateCell()
cell.Value = "Custom Format"
cell.ApplyFormatting(formatting)
End Using
End Using
End Using
End Using
Object XlFormatting XlCellFormatting
See Also