Back to Devexpress

CellRange.BeginUpdateFormatting() Method

officefileapi-devexpress-dot-spreadsheet-dot-cellrange-fb821faf.md

latest10.0 KB
Original Source

CellRange.BeginUpdateFormatting() Method

Starts modifying the cell range formatting.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Formatting BeginUpdateFormatting()
vb
Function BeginUpdateFormatting As Formatting

Returns

TypeDescription
Formatting

A Formatting object representing the cell range formatting.

|

Example

This example demonstrates how to format cells in a worksheet.

View Example

csharp
// Access the cell to be formatted.
Cell cell = worksheet.Cells["B2"];

// Specify font settings (font name, color, size and style).
cell.Font.Name = "MV Boli";
cell.Font.Color = Color.Blue;
cell.Font.Size = 14;
cell.Font.FontStyle = SpreadsheetFontStyle.Bold;

// Specify cell background color.
cell.Fill.BackgroundColor = Color.LightSkyBlue;

// Specify text alignment in the cell. 
cell.Alignment.Vertical = SpreadsheetVerticalAlignment.Center;
cell.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
// Access the range of cells to be formatted.
CellRange range = worksheet.Range["C3:E6"];

// Begin updating of the range formatting. 
Formatting rangeFormatting = range.BeginUpdateFormatting();

// Specify font settings (font name, color, size and style).
rangeFormatting.Font.Name = "MV Boli";
rangeFormatting.Font.Color = Color.Blue;
rangeFormatting.Font.Size = 14;
rangeFormatting.Font.FontStyle = SpreadsheetFontStyle.Bold;

// Specify cell background color.
rangeFormatting.Fill.BackgroundColor = Color.LightSkyBlue;

// Specify text alignment in cells.
rangeFormatting.Alignment.Vertical = SpreadsheetVerticalAlignment.Center;
rangeFormatting.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;

// End updating of the range formatting.
range.EndUpdateFormatting(rangeFormatting);
vb
' Access the cell to be formatted.
Dim cell As Cell = worksheet.Cells("B2")

' Specify font settings (font name, color, size and style).
cell.Font.Name = "MV Boli"
cell.Font.Color = Color.Blue
cell.Font.Size = 14
cell.Font.FontStyle = SpreadsheetFontStyle.Bold

' Specify cell background color.
cell.Fill.BackgroundColor = Color.LightSkyBlue

' Specify text alignment in the cell. 
cell.Alignment.Vertical = SpreadsheetVerticalAlignment.Center
cell.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center
' Access the range of cells to be formatted.
Dim range As CellRange = worksheet.Range("C3:E6")

' Begin updating of the range formatting. 
Dim rangeFormatting As Formatting = range.BeginUpdateFormatting()

' Specify font settings (font name, color, size and style).
rangeFormatting.Font.Name = "MV Boli"
rangeFormatting.Font.Color = Color.Blue
rangeFormatting.Font.Size = 14
rangeFormatting.Font.FontStyle = SpreadsheetFontStyle.Bold

' Specify cell background color.
rangeFormatting.Fill.BackgroundColor = Color.LightSkyBlue

' Specify text alignment in cells.
rangeFormatting.Alignment.Vertical = SpreadsheetVerticalAlignment.Center
rangeFormatting.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center

' End updating of the range formatting.
range.EndUpdateFormatting(rangeFormatting)

The following code snippets (auto-collected from DevExpress Examples) contain references to the BeginUpdateFormatting() method.

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.

winforms-spreadsheetcontrol-api-part1/CS/SpreadsheetControl/SpreadsheetActions/FormattingActions.cs#L286

csharp
CellRange range = worksheet.Range["C3:H10"];
Formatting rangeFormatting = range.BeginUpdateFormatting();
rangeFormatting.Font.Color = Color.Blue;

asp-net-mvc-spreadsheet-modify-document/CS/DXWebApplication1/Controllers/HomeController.cs#L30

csharp
CellRange priceRange = worksheet.Range["C2:C15"];
Formatting rangeFormatting = priceRange.BeginUpdateFormatting();
rangeFormatting.Font.Color = Color.SandyBrown;

spreadsheet-document-api-create-loan-amortization-schedule-within-blazor-server-app/CS/BlazorAppSpreadsheet/Code/DocumentGenerator.cs#L174

csharp
range = Sheet["B11:K" + ActualLastRow];
Formatting formatting = range.BeginUpdateFormatting();
try

wpf-spreadsheetcontrol-api-part-1/CS/SpreadsheetControl_WPF_API/SpreadsheetActions/FormattingActions.cs#L290

csharp
CellRange range = worksheet.Range["C3:H10"];
Formatting rangeFormatting = range.BeginUpdateFormatting();
rangeFormatting.Font.Color = Color.Blue;

spreadsheet-document-api-examples-part1/CS/SpreadsheetExamples/SpreadsheetActions/FormattingActions.cs#L234

csharp
CellRange range = worksheet.Range["C3:D4"];
Formatting rangeFormatting = range.BeginUpdateFormatting();
rangeFormatting.Font.Color = Color.Blue;

spreadsheet-document-api-examples-part1/VB/SpreadsheetExamples/SpreadsheetActions/FormattingActions.vb#L113

vb
' Start to update the cell range formatting.
Dim rangeFormatting As Formatting = range.BeginUpdateFormatting()
' Specify font settings (font name, color, size and style).

winforms-dashboard-customize-exported-document/VB/CustomExportDocumentExample/Form1.vb#L53

vb
sheet.MergeCells(sheet.Range.FromLTRB(5, 0, 8, 0))
Dim formatting As Formatting = textCell.BeginUpdateFormatting()
formatting.Fill.BackgroundColor = Color.LightBlue

winforms-spreadsheetcontrol-api-part1/VB/SpreadsheetControl/SpreadsheetActions/FormattingActions.vb#L279

vb
Dim range As CellRange = worksheet.Range("C3:H10")
Dim rangeFormatting As Formatting = range.BeginUpdateFormatting()
rangeFormatting.Font.Color = Color.Blue

asp-net-mvc-spreadsheet-modify-document/VB/DXWebApplication1/Controllers/HomeController.vb#L23

vb
Dim priceRange As CellRange = worksheet.Range("C2:C15")
Dim rangeFormatting As Formatting = priceRange.BeginUpdateFormatting()
rangeFormatting.Font.Color = Color.SandyBrown

wpf-spreadsheetcontrol-api-part-1/VB/SpreadsheetControl_WPF_API/SpreadsheetActions/FormattingActions.vb#L282

vb
Dim range As CellRange = worksheet.Range("C3:H10")
Dim rangeFormatting As Formatting = range.BeginUpdateFormatting()
rangeFormatting.Font.Color = Color.Blue

See Also

CellRange Interface

CellRange Members

DevExpress.Spreadsheet Namespace