Skip to content

Explore a collection of concise C# examples and Gists showcasing efficient ways to manipulate Word documents using the FileFormat.Words C# API. Simplify document processing tasks with these practical code snippets for enhanced Word document handling.

License

Notifications You must be signed in to change notification settings

fileformat-words-gists/FileFormat.Words-for-.NET

Repository files navigation

C# Word Document API Examples

FileFormat.Words.Examples - C# code examples using FileFormat.Words for .NET - A versatile API for creating, loading, and modifying MS Word documents.

Table of Contents

  • Creates a new Word Document with structured content using FileFormat.Words
  • Generates paragraphs with heading styles defined by the Word document template.
  • Adds normal paragraphs under each heading paragraph.
  • Includes text runs with various fonts as per the template.
  • Saves the newly created Word Document.
  • Click here to explore gist.
  • Loads an existing Word Document with structured content using FileFormat.Words
  • Traverses paragraphs and displays associated styles as defined by the Word document template.
  • Traverses through each run (text fragment) within each paragraph and displays fragment values.
  • Click here to explore gist
  • Loads an existing Word Document with structured content using FileFormat.Words
  • Modifies paragraphs by prepending 'Modified Heading :' for styled paragraphs and 'Modified Run :' for each run within normal paragraphs, preserving the existing format.
  • Saves the modified Word Document.
  • Click here to explore gist
  • Creates a new Word Document with structured content using FileFormat.Words
  • Loads images from the specified diretory and decodes using SkiaSharp.
  • Creates a word document and appends loaded images to it.
  • Saves the newly created Word Document.
  • Click here to explore gist
  • Loads an existing Word Document with structured content using FileFormat.Words
  • Gets images from the word document. Decodes image using SkiaSharp and encode to JPG.
  • Resize image to 250(height) and 200(width).
  • Saves the modified Word Document.
  • Click here to explore gist
  • Creates a new Word Document with structured content using FileFormat.Words
  • Generates 5(rows) x 3(cols) tables with table styles defined by the Word document template.
  • Appends each table to the body of the word document.
  • Saves the newly created Word Document.
  • Click here to explore gist
  • Loads an existing Word Document with structured content using FileFormat.Words
  • Traverses tables and displays associated styles as defined by the Word document template.
  • Traverses through each row and then traverses columns within the row.
  • Traverses through paragrpahs within each cell and displays paragraph plain text
  • Click here to explore gist
  • Creates a new Word Document with structured content using FileFormat.Words
  • Generates paragraphs with different alignments including left, center, right and justify.
  • Saves the newly created Word Document.
  • Click here to explore gist
  • Loads a Word Document with structured content using FileFormat.Words
  • Traverses through all paragraphs within the document.
  • Modifies paragraphs by appending ' (alignment modified to justify)' with italic format and justify alignment.
  • Saves the modified Word Document.
  • Click here to explore gist
  • Creates a new Word Document with structured content using FileFormat.Words
  • Generates paragraphs with different indents including left, right, firstline and hanging.
  • Saves the newly created Word Document.
  • Click here to explore gist
  • Loads a Word Document with structured content using FileFormat.Words
  • Traverses through all paragraphs within the document.
  • Modifies paragraphs by appending the relevant indent message in italic format and modifies the indent (if found) to 0.
  • Saves the modified Word Document.
  • Click here to explore gist
  • Loads a Word Document with structured content using FileFormat.Words
  • Traverses through all paragraphs within the document.
  • If numbered, modifies paragraphs by appending ' (numering removed)' with italic format and paragraph number is removed.
  • Saves the modified Word Document.
  • Click here to explore gist
  • Loads a Word Document with structured content using FileFormat.Words
  • Traverses through all paragraphs within the document.
  • If alphabetic, modifies paragraphs by appending ' (alphabetic removed)' with italic format and paragraph alphabetic is removed.
  • Saves the modified Word Document.
  • Click here to explore gist
  • Creates a new Word Document with structured content using FileFormat.Words
  • Generates two multilevel lists with different prefixes at different levels.
  • Saves the newly created Word Document.
  • Click here to explore gist
  • Loads a Word Document with structured content using FileFormat.Words
  • Traverses through all paragraphs within the document.
  • If list paragraphs, modifies paragraphs by appending ' (numbering type changed to numeric)' with italic format and paragraph numbering type is changed to numeric.
  • Saves the modified Word Document.
  • Click here to explore gist
  • Creates a new Word Document with structured content using FileFormat.Words
  • Generates two multilevel lists with different prefixes at different levels.
  • Saves the newly created Word Document.
  • Click here to explore gist
  • Loads a Word Document with structured content using FileFormat.Words
  • Traverses through all paragraphs within the document.
  • If list paragraphs, modifies paragraphs by appending ' (numbering type changed to numeric)' with italic format and paragraph numbering type is changed to numeric.
  • Saves the modified Word Document.
  • Click here to explore gist

Resources

System Requirements

Quick Start

// Prepares directory at the root of your project.
// Default is 'Documents/Paragraph' unless specified otherwise as param.
var paragraphExamples = new ParagraphExamples();
// Creates a word document with paragraphs and saves word document to the specified 
// directory. Default is 'Documents/Paragraph/WordParagraphs.docx' unless specified otherwise as param.
paragraphExamples.CreateWordParagraphs();
// Reads Paragraphs from the specified Word Document and displays plain text and formatting.
// Default is 'Documents/Paragraph/WordParagraphs.docx' unless specified otherwise as param.
paragraphExamples.ReadWordParagraphs();
// Modifies Paragraphs in the specified Word Document and saves the modified word document.
// Default document to modify is 'Documents/Paragraph/WordParagraphs.docx' unless specified otherise as param.
// Default modified document is saved as 'Documents/Paragraph/WordParagraphs.docx' unless specified otherise as param.
paragraphExamples.ModifyWordParagraphs();

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Explore a collection of concise C# examples and Gists showcasing efficient ways to manipulate Word documents using the FileFormat.Words C# API. Simplify document processing tasks with these practical code snippets for enhanced Word document handling.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages