Office File API & Office-Inspired Desktop UI Controls (WinForms & WPF) – Tips & Tricks (April-May 2021)

We have compiled a list of interesting support tickets answered throughout April and May. We hope you find these support tickets interesting and of business value. Should you have any questions, feel free to comment below.

Tips & Tricks

PDF Document API

Word Processing Document API

Spreadsheet Document API

ZIP Compression and Archive API

WinForms and WPF Rich Text Editors

WinForms Spreadsheet Control

WinForms PDF Viewer


WinForms and WPF Rich Text Editors

Spreadsheet Document API and Spreadsheet Controls (for WinForms and WPF)

  • T984750 - The PasteSpecial enumeration now includes DataValidations and Hyperlinks members

    New enumeration members allow you to specify whether to paste data validation rules and hyperlinks from copied cells into target cells.
    The following code sample demonstrates how to paste copied cells without data validation rules:

    spreadsheetControl1.CopiedRangePasting += (s, e) =>
       e.PasteSpecialFlags = PasteSpecial.All & ~PasteSpecial.DataValidations;
  • T993314 - The CellRange.Select(CellRange) extension method now does not expand cell selection to include merged cells

    Use a new CellRange.Select method overload with the expandToMergedCells parameter to specify whether to include merged cells in the selected range.

  • T998681 – Use a new Worksheet.CopyFrom method overload to specify copy options

    Pass a WorksheetCopyOptions class instance to the Worksheet.CopyFrom method to define copy options when you copy data from one worksheet to another. New options allow you to map worksheets from the source workbook to worksheets in the target workbook, specify Paste Special options, use external references for invalid formulas, or replace these formulas with calculated values.
    The following example copies all worksheets from one workbook to another:

    using (Workbook sourceWorkbook = new Workbook())
    using (Workbook targetWorkbook = new Workbook())
        // Specify mappings between source worksheets and
        // target worksheets. Target worksheets will have
        // the same name as source worksheets.
        var sheetMappings = SpecifySheetMappings(sourceWorkbook);
        // Copy all worksheets from a source workbook to target workbook.
        CopySheetsToWorbook(sourceWorkbook, targetWorkbook, sheetMappings);
    private static WorksheetCopyOptions SpecifySheetMappings(Workbook sourceWorkbook)
        var options = new WorksheetCopyOptions();
        foreach (var sheet in sourceWorkbook.Worksheets)
            options.SheetMappings.Add(sheet.Name, sheet.Name);
            return options;
    private static void CopySheetsToWorbook(Workbook sourceWorkbook, 
    	Workbook targetWorkbook, WorksheetCopyOptions options)
         foreach (var sheet in sourceWorkbook.Worksheets)
            string sheetName = sheet.Name;
            if (!targetWorkbook.Worksheets.Contains(sheetName))
             targetWorkbook.Worksheets[sheetName].CopyFrom(sheet, options);
  • T983690 – We added a DocumentSettings.CompressImages property to preserve the "Do not compress images in file" option for Excel documents (XLSX, XLSB, XLS)

WinForms and WPF PDF Viewer

  • T995535 – Handle our new ReplyCreated, ReplyChanged, and ReplyDeleted events to determine if a reply was added, changed or removed in the Comments panel
  • T995534 - The AnnotationChanged event now fires when a user edits an annotation in the Comments panel
  • T989060 – The PDF Viewer now displays a security warning dialog before executing a launch action

  • T982636 - We implemented a ShellExecuting event that fires when the PDF Viewer executes a launch action (opens a non-PDF file or launches an arbitrary application). You can handle this event to disable our default security warning dialog.

    The code sample below disables the warning dialog if the PDF Viewer tries to launch the PdfViewerDemo.exe application:

    private void pdfViewer_ShellExecuting(object sender,
            DevExpress.XtraPdfViewer.PdfShellExecutingEventArgs e)
        string demoPath =
            @" C:\Users\Public\Documents\DevExpress Demos 21.1\Components\WinForms\Bin\PdfViewerDemo.exe";
        if (e.FilePath == demoPath) { e.Handled = true; }

As always, if you’ve come across an interesting support ticket that you’d like to share with the rest of the DevExpress developer community, please comment below and include the appropriate link.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.