Skip to content

Instantly share code, notes, and snippets.

View fileformat-words-gists's full-sized avatar

fileformat-words-gists

View GitHub Profile
@fileformat-words-gists
fileformat-words-gists / Modify-Multiple-Multilevel-List-Paragraphs.cs
Last active May 16, 2024 20:39
C# Modify Multiple Multilevel List Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"MultilevelLists.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
foreach (var paragraph in body.Paragraphs)
{
@fileformat-words-gists
fileformat-words-gists / Read-Multiple-Multilevel-List-Paragraphs.cs
Last active May 16, 2024 18:12
C# Read Multiple Multilevel List Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"MultilevelLists.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
//System.Collections.Generic.List<FileFormat.Words.IElements.Paragraph>
// paragraphs = body.Paragraphs;
@fileformat-words-gists
fileformat-words-gists / Create-Multiple-Multilevel-List-Paragraphs.cs
Created May 16, 2024 17:45
C# Create Multiple Multilevel List Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// The resulting docx document should be like this: https://i.imgur.com/6PKIb56.png
// Initialize docx document
FileFormat.Words.Document doc = new FileFormat.Words.Document();
System.Console.WriteLine("Word Document with default template initialized");
// Initialize document body
var body = new FileFormat.Words.Body(doc);
@fileformat-words-gists
fileformat-words-gists / Modify-Roman-Alphabetic-Paragraphs.cs
Last active May 16, 2024 18:11
C# Modify Roman Alphabetic Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"WordParagraphsRomanAlphabetic.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
//foreach (FileFormat.Words.IElements.Paragraph paragraph in body.Paragraphs)
foreach (var paragraph in body.Paragraphs)
@fileformat-words-gists
fileformat-words-gists / Read-Roman-Alphabetic-Paragraphs.cs
Last active May 16, 2024 18:09
C# Read Roman Alphabetic Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"WordParagraphsRomanAlphabetic.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
//System.Collections.Generic.List<FileFormat.Words.IElements.Paragraph>
// paragraphs = body.Paragraphs;
@fileformat-words-gists
fileformat-words-gists / Create-Roman-Alphabetic-Paragraphs.cs
Last active May 16, 2024 18:06
C# Create Roman Alphabetic Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Initialize docx document
FileFormat.Words.Document doc = new FileFormat.Words.Document();
System.Console.WriteLine("Word Document with default template initialized");
// Initialize document body
var body = new FileFormat.Words.Body(doc);
System.Console.WriteLine("Body of the Word Document initialized");
@fileformat-words-gists
fileformat-words-gists / Modify-Numbered-Word-Paragraphs.cs
Last active May 16, 2024 18:03
C# Modify Numbered Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"WordParagraphsNumbered.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
//foreach (FileFormat.Words.IElements.Paragraph paragraph in body.Paragraphs)
foreach (var paragraph in body.Paragraphs)
@fileformat-words-gists
fileformat-words-gists / Read-Numbered-Word-Paragraphs.cs
Last active May 16, 2024 18:01
C# Read Numbered Paragraphs in Word Document
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"WordParagraphsNumbered.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
//System.Collections.Generic.List<FileFormat.Words.IElements.Paragraph>
// paragraphs = body.Paragraphs;
@fileformat-words-gists
fileformat-words-gists / Create-Numbered-Word-Paragraphs.cs
Last active May 16, 2024 17:59
C# Create Numbered Paragraphs in Word Document
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Initialize docx document
FileFormat.Words.Document doc = new FileFormat.Words.Document();
System.Console.WriteLine("Word Document with default template initialized");
// Initialize document body
var body = new FileFormat.Words.Body(doc);
System.Console.WriteLine("Body of the Word Document initialized");
@fileformat-words-gists
fileformat-words-gists / Modify-Word-Paragraph-Indent.cs
Created March 3, 2024 10:35
C# Modify Word Paragraph Indent
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"filename.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
foreach (FileFormat.Words.IElements.Paragraph paragraph in body.Paragraphs)
{