Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2370

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

$
0
0

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

PDF Document API

  1. T924826 - How to restore a clip region in a PDF document
    https://supportcenter.devexpress.com/ticket/details/T924826

Rich Text Editor

  1. T914899 - How to filter the language list in the Language dialog
    https://supportcenter.devexpress.com/ticket/details/T914899
  2. T915274 - How to count words in a document
    https://supportcenter.devexpress.com/ticket/details/T915274

    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)
            {
                Buffer.Append(text.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[] { ' ', '.', '!', '?' }, 
                StringSplitOptions.RemoveEmptyEntries).Length;
                if (!string.IsNullOrWhiteSpace(text))
                    Buffer.Length = 0;
            }
    
            public override void Visit(DocumentSectionEnd sectionEnd)
            {
                FinishParagraph();
            }
            public override void Visit(DocumentParagraphEnd paragraphEnd)
            {
                FinishParagraph();
            }
    
        }
    
        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())
                    iterator.Current.Accept(visitor);
               
    	  // 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
    https://supportcenter.devexpress.com/ticket/details/T923827

WinForms PDF Viewer

  1. T920036 - How to mark a location for a signature in a PDF document
    https://supportcenter.devexpress.com/ticket/details/T920036

WPF PDF Viewer

  1. T919109 - How to implement Fit to Height zoom mode
    https://supportcenter.devexpress.com/ticket/details/T919109

WPF Spreadsheet Control

  1. T922458 - How to copy a cell range in one SpreadsheetControl and paste only cell values to a different SpreadsheetControl
    https://supportcenter.devexpress.com/ticket/details/T922458

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

Enhancements

Spreadsheet Document API

  1. T917379 – You can now hide filter drop-down arrows in a pivot table
    https://supportcenter.devexpress.com/ticket/details/T917379

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

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

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.


Viewing all articles
Browse latest Browse all 2370

Trending Articles