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.

Namespace: DevExpress.XtraSpreadsheet

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

[DefaultValue(false)]
public bool KeepSourceThemeFonts { get; set; }

Property Value

Type Default Description
Boolean false

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
DocumentOptions
.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 copied data, set the KeepSourceThemeColors and KeepSourceThemeFonts properties for the destination workbook 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.
destinationWorkbook.Options.Copy.KeepSourceThemeColors = true;
destinationWorkbook.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, specify the following properties for the source document to preserve its theme colors and fonts:

See Also