Back to Devexpress

Style.CopyFrom(BuiltInStyleId) Method

officefileapi-devexpress-dot-spreadsheet-dot-style-dot-copyfrom-x28-devexpress-dot-spreadsheet-dot-builtinstyleid-x29.md

latest3.9 KB
Original Source

Style.CopyFrom(BuiltInStyleId) Method

Duplicates the format settings of the specified built-in style into the current Style instance.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void CopyFrom(
    BuiltInStyleId id
)
vb
Sub CopyFrom(
    id As BuiltInStyleId
)

Parameters

NameTypeDescription
idBuiltInStyleId

A cell style from which format settings should be copied.

|

Remarks

You can duplicate a built-in style using the CopyFrom property to create your own custom style. For more information on cell styles and examples on how to manage them, see the Formatting Cells and How to: Create or Modify a Style topics.

Example

  1. Use the StyleCollection.Add method to add a new style to the Workbook.Styles collection.

  2. Call the Style.CopyFrom method for the created style to copy all format settings from the specified Microsoft® Excel® built-in style to the new style.

View Example

csharp
// Add a new style under the "My Good Style" name to the style collection.
Style myGoodStyle = workbook.Styles.Add("My Good Style");

// Copy all format settings from the built-in Good style.
myGoodStyle.CopyFrom(BuiltInStyleId.Good);

// Modify the style's format characteristics if needed.
// ...
vb
' Add a new style under the "My Good Style" name to the style collection.
Dim myGoodStyle As Style = workbook.Styles.Add("My Good Style")

' Copy all format settings from the built-in Good style.
myGoodStyle.CopyFrom(BuiltInStyleId.Good)

' Modify the style's format characteristics if needed.
' ...

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CopyFrom(BuiltInStyleId) 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.

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

vb
' Copy all format settings from the built-in Good style.
myGoodStyle.CopyFrom(BuiltInStyleId.Good)
' Modify the required formatting characteristics if needed.

See Also

Style Interface

Style Members

DevExpress.Spreadsheet Namespace