Skip to main content

SpreadsheetCopyOptions.KeepSourceThemeColors Property

Gets or sets a value indicating whether to keep theme colors for data copied from a workbook with a different theme.

Namespace: DevExpress.XtraSpreadsheet

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

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

Property Value

Type Default Description
Boolean false

true, to keep theme colors for inserted data; otherwise, false.

Property Paths

You can access this nested property as listed below:

Object Type Path to KeepSourceThemeColors
DocumentOptions
.Copy .KeepSourceThemeColors

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