SpreadsheetCopyOptions.KeepSourceThemeColors Property

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

Namespace: DevExpress.Xpf.Spreadsheet

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

Declaration

public bool KeepSourceThemeColors { get; set; }
Public Property KeepSourceThemeColors As Boolean

Property Value

Type Description
Boolean

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
SpreadsheetControl
.Options.Copy.KeepSourceThemeColors
SpreadsheetControlOptions
.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 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