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

Enhancements

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
    https://supportcenter.devexpress.com/ticket/details/T984750

    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
    https://supportcenter.devexpress.com/ticket/details/T993314

    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
    https://supportcenter.devexpress.com/ticket/details/T998681

    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())
    {
        targetWorkbook.LoadDocument(@"Documents\Book1.xlsx");
        sourceWorkbook.LoadDocument(@"Documents\Book2.xlsx");
        
        // 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);
        targetWorkbook.Calculate();
        targetWorkbook.SaveDocument("Result.xlsx");
     }
    
    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.Add(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)
    https://supportcenter.devexpress.com/ticket/details/T983690

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
    https://supportcenter.devexpress.com/ticket/details/T995535
  • T995534 - The AnnotationChanged event now fires when a user edits an annotation in the Comments panel https://supportcenter.devexpress.com/ticket/details/T995534
  • T989060 – The PDF Viewer now displays a security warning dialog before executing a launch action

    https://supportcenter.devexpress.com/ticket/details/T989060

  • 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.
    https://supportcenter.devexpress.com/ticket/details/T982636

    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 Xamarin UI Controls

Deliver high-impact native mobile apps with our feature-rich Data Grid, Scheduler, Chart, TabView, Editors, and utility controls. Reserve your free copy today!
No Comments

Please login or register to post comments.