Reviewed by: Diana on 2018-06-25
Create, load, and modify Word files with ease
A high-performance and reliable Word library which lets you add create, load, and manipulate Word documents right in your .NET applications easily with a few lines of code
Ultimate Word's Key Features
Document Features
• Create a new Word document • Load an existing Word document for editing • Load document from file system or stream • Write the Word document to a local file, stream, or open it in the client browser • Create, get, and modify paragraphs and text • Create, get, and modify tables, rows, and cells • Create, get, and modify hyperlinks • Create, get, and modify bookmarks • Get, create, and modify document headers, footer, and sections • Find and replace text • Find a specific word or phrase • Find text using a regular expression • Replace text with another text or other content sources including the document's contents • Keep text formatting while replacing • Access document contents • Copy and move document elements between documents • Merge multiple Word documents • Create, get, and modify Table of Contents (TOC) • Rebuild and update TOC • Create, get, and modify footnotes and endnotes • Structured Document Tags (Content Controls) are preserved • Accept, reject or delete a particular revision or all the revisions • Create, load, and modify OLE objects from the document • Insert custom HTML text • Insert watermarks • Create, get, and modify fields • Update IF, Formula and other fields • Create, get, and modify form fields
Document Settings and Properties
• Get and modify built-in document properties • Get and modify custom document properties • Encrypt documents • Control the type of changes by setting document protection • Open password-protected documents • Create, get, and modify comments
Mail merge
• Create, get, and modify merge fields • Get mail merge field names • Insert images during mail merge process • Apply formatting during mail merge process using events • Supports for complex merge fields • Supports performing mail merge on a specified region • Supports for reports that contain relational details (parent-child data) • Supports for any .NET data source such as string array, DataTable, DataView, DataReader, DataSet • Supports for any data source such as business objects and dynamic objects
Document Formatting
• Character formatting: font size, font color, font name, bold, italic, underline, etc. • Paragraph formatting: line spacing, alignment, indentation, spacing before and after, keep follow, etc. • Bulleted and numbered lists formatting: numbering and levels • Table formatting: alignment, borders, and shading • Get and modify section properties such as margins, paper size, and orientation • Get, create, and modify paragraph styles • Apply predefined table styles
Bookmark
• Load, create and manipulate bookmarks • Supports for bookmark navigation • Retrieve document contents in a bookmark range and merge to a new or an existing document • Add text or document contents between the specified bookmarks • Replace contents of a document in the bookmark range with text or contens from another document • Delete contents of the Word document between the specified bookmark range
What is Word?
Microsoft Word (often MS Word, WinWord or simply Word) is a word processor designed for creating, viewing and editing text documents, with local application of the simplest forms of table-matrix algorithms. Produced by Microsoft in the package Microsoft Office
Creating a project using the Word component
Let's create a simple WPF application using the Word component We’ll need to add the necessary links to our project. Therefore, click on "Links" and select "Add link" We’ll need to select such links - ComponentPro.Word.dll. Which, I remind, are in the Extensions Loading the contents of a document in Word
OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Word files (.doc;.docx)|*.doc;;*.docx|All Files (*.*)|*.*"; dlg.FilterIndex = 1; if (dlg.ShowDialog() == true) { string message = null; // Open the selected file for reading. try { using (System.IO.Stream fileStream = dlg.File.OpenRead()) { WordDocument document = new WordDocument(fileStream); message = string.Format("Word file loaded successfully and it has {0} section(s)", document.Sections.Count); document.Close(); } } catch (Exception ex) { message = "File load failed. Error: " + ex.Message; } lblMessage.Content = message;
Save changes to a document in Word
try { string message = null; using (Stream fileStream = dlg.OpenFile()) { WordDocument document = new WordDocument(); // Add a new document to the document. ComponentPro.Word.Section firstSection = document.AddSection(); // Add text to the document. ComponentPro.Word.Paragraph paragraph = firstSection.AddParagraph(); paragraph.AppendText("Ultimate Word for .NET is a 100%-managed Word document component that helps you add Word capabilities in your .NET applications. " + "With a few lines of code, you can create a complex Word document from scratch or load an existing Word file."); document.Save(fileStream, WordDocumentFormat.Word2007); // Close the document. document.Close(); } message = "File saved successfully."; } catch (Exception ex) { message = "Error saving Word file. Error: " + ex.Message; }
Conclusions and recommendations With Word library, you can fully manage and customize your document using only the code of the library. Many libraries have only superficial functionality for document filling, recording, reading. And here there is everything together and with good optimization, which is a very good plus. Formatting, editing, creating and other important settings over your Word document, and all this with convenient and intuitive code inside the library.
If you have found a broken link, please contact us
|