Office File API & Office-Inspired Desktop UI Controls – Tips & Tricks (August 2020)

Office-Inspired Products
23 September 2020

We’ve compiled a list of interesting support tickets answered throughout July and August. Hopefully, you’ll find these support tickets of value as you explore and leverage the capabilities of our Office File API and Desktop Office-inspired UI components. Should you have any questions about these support tickets, feel free to comment below.

Tips & Tricks

Spreadsheet Document API

  1. T920110 - How to expand or collapse a pivot item’s outline

PDF Document API

  1. T924826 - How to restore a clip region in a PDF document

Rich Text Editor

  1. T914899 - How to filter the language list in the Language dialog
  2. T915274 - How to count words in a document

    You can use the Visitor-Iterator pattern to count words. Create a DocumentVisitorBase implementation and override the corresponding DocumentVisitorBase.Visit methods. Create DocumentIterator and StatisticsVisitor instances in the main class. Call the MoveNext and Accept methods to move through document text and collect statistics.

    public class StatisticsVisitor : DocumentVisitorBase
            readonly StringBuilder _buffer;
            int _wordCount;
            public StatisticsVisitor()
                this._buffer = new StringBuilder();
    	// Declare properties used to return the text buffer
    	// and word count
            StringBuilder Buffer { get { return _buffer; } }
            public int WordCount { get { return _wordCount; } }
            // Add document text to the buffer     
            public override void Visit(DocumentText text)
            // Split buffer text into words and count them.     
           // This method is called when the visitor encounters section and 
            paragraph ends   
            void FinishParagraph()
                string text = Buffer.ToString();
                this._wordCount += text.Split(new char[] { ' ', '.', '!', '?' }, 
                if (!string.IsNullOrWhiteSpace(text))
                    Buffer.Length = 0;
            public override void Visit(DocumentSectionEnd sectionEnd)
            public override void Visit(DocumentParagraphEnd paragraphEnd)
        public partial class Form1 
    	// In this example, words are counted on button click:
            private void countWordsBarButtonItem_ItemClick(object sender, 
            DevExpress.XtraBars.ItemClickEventArgs e)
    	 // Create iterator and visitor objects            
    	 DocumentIterator iterator = new DocumentIterator(richEditControl1.Document, true);
             StatisticsVisitor visitor = new StatisticsVisitor();
              // Allow the visitor to retrieve encountered document elements            
    	  while (iterator.MoveNext())
    	  // Show result in a message box
    	  MessageBox.Show(String.Format("{0} WORDS", visitor.WordCount));
  3. T923827 - How to show SuperToolTip until a user clicks somewhere different

WinForms PDF Viewer

  1. T920036 - How to mark a location for a signature in a PDF document

WPF PDF Viewer

  1. T919109 - How to implement Fit to Height zoom mode

WPF Spreadsheet Control

  1. T922458 - How to copy a cell range in one SpreadsheetControl and paste only cell values to a different SpreadsheetControl

    Handle the SpreadsheetControl.ClipboardDataObtained event and set the e.Flags property to PasteSpecial.Values to paste only cell values from the clipboard.

    private void spreadsheet_ClipboardDataObtained(object sender, 
            DevExpress.Spreadsheet.ClipboardDataObtainedEventArgs e)
        e.Flags = DevExpress.Spreadsheet.PasteSpecial.Values;

WinForms Spreadsheet Control

  1. T919991 - How to expand a drop-down list for a cell for which a List data validation rule has been applied


Spreadsheet Document API

  1. T917379 – You can now hide filter drop-down arrows in a pivot table

    Set the PivotViewOptions.ShowFieldHeaders property to false to hide drop-down buttons within PivotTable field headers. In this instance, end users will not be able to sort or filter field items.

    // Hide drop-down button for the Product field. 
     pivotTable.Fields["Product"].ShowHeaderDropDown = false;

PDF Document API

  1. T923412 - Check if a document has a certification signature

    We added a GetSignatureInfo method (used to retrieve information about document signatures). Each PdfSignatureInfo object - contained in the returned collection - allows you to check the signature’s certification level.

    using (var signer = new PdfDocumentSigner(@"D://Docs//SignedDocument.pdf"))
        var signatures = signer.GetSignatureInfo();
        for (int i = 0; i < signatures.Count; i++)
            Console.WriteLine(String.Format("{0} signature certification level: {1}",
                i, signatures[i].CertificationLevel));
  2. T925676 - You can now set a predefined date and time for a signature

If you’ve come across an interesting support ticket 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.