Skip to main content

SpreadsheetCopyOptions.KeepSourceThemeFonts Property

Gets or sets a value indicating whether to keep major and minor theme fonts for data copied from a workbook with a different theme. This is a dependency property.

Namespace: DevExpress.Xpf.Spreadsheet

Assembly: DevExpress.Xpf.Spreadsheet.v24.1.dll

NuGet Package: DevExpress.Wpf.Spreadsheet

Declaration

public bool KeepSourceThemeFonts { get; set; }

Property Value

Type Description
Boolean

true, to keep theme fonts for copied data; otherwise, false.

Property Paths

You can access this nested property as listed below:

Object Type Path to KeepSourceThemeFonts
SpreadsheetControlOptions
.Copy .KeepSourceThemeFonts

Remarks

When you programmatically copy worksheets or cell ranges between workbooks with different themes applied, theme formatting changes for inserted data to use the destination workbook’s theme colors and fonts.

To preserve theme formatting applied to inserted data, set the KeepSourceThemeColors and KeepSourceThemeFonts properties for the target control to true. In this case, theme colors are converted to the corresponding custom RGB colors, and theme fonts become user-defined fonts with the font scheme None.

// Load a workbook with the Office theme applied.
IWorkbook destinationWorkbook = spreadsheetControl1.Document;
destinationWorkbook.LoadDocument("OfficeTheme.xlsx", DocumentFormat.Xlsx);

// Specify copy options to preserve theme formatting for inserted content.
spreadsheetControl1.Options.Copy.KeepSourceThemeColors = true;
spreadsheetControl1.Options.Copy.KeepSourceThemeFonts = true;

// Load a workbook with the Quotable theme applied.
IWorkbook sourceWorkbook = spreadsheetControl2.Document;
sourceWorkbook.LoadDocument("QuotableTheme.xlsx", DocumentFormat.Xlsx);

// Copy the first worksheet from the source workbook to the destination workbook.
// The inserted worksheet retains colors and fonts of the Quotable theme.
Worksheet destinationWorksheet = destinationWorkbook.Worksheets.Add();
destinationWorksheet.CopyFrom(sourceWorkbook.Worksheets[0]);

If you copy data from the SpreadsheetControl to an external spreadsheet application (another SpreadsheetControl instance or Microsoft® Excel®) in the UI, use the following properties to preserve the source document’s theme colors and fonts:

See Also