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-Word-Group-Shapes.cs
Last active December 31, 2024 12:36
Modify Word Group Shapes
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"WordGroupShapes.docx");
// Initialize the body with the loaded document.
var body = new FileFormat.Words.Body(doc);
// Load all group shapes
var groupShapes = body.GroupShapes;
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document.
var doc = new FileFormat.Words.Document($"WordGroupShapes.docx");
// Initialize the body with the loaded document.
var body = new FileFormat.Words.Body(doc);
// Load all group shapes with the document
var groupShapes = body.GroupShapes;
@fileformat-words-gists
fileformat-words-gists / Create-Word-Group-Shapes.cs
Created December 31, 2024 12:23
Create Word Group Shapes
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Initialize a new word document with the default template
var doc = new FileFormat.Words.Document();
System.Console.WriteLine("Word Document with default template initialized");
// Initialize the body with the new document
var body = new FileFormat.Words.Body(doc);
System.Console.WriteLine("Body of the Word Document initialized");
@fileformat-words-gists
fileformat-words-gists / Modify-Word-Shapes.cs
Created September 30, 2024 09:21
C# Create Modify Shapes 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($"shapes.docx");
// Initialize the body with the loaded document.
var body = new FileFormat.Words.Body(doc);
// Load all shapes
var shapes = body.Shapes;
@fileformat-words-gists
fileformat-words-gists / Read-Word-Shapes.cs
Last active September 30, 2024 09:22
C# Read Shapes 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($"shapes.docx");
// Initialize the body with the loaded document.
var body = new FileFormat.Words.Body(doc);
// Load all shapes with the document
var shapes = body.Shapes;
@fileformat-words-gists
fileformat-words-gists / Create-Word-Shapes.cs
Last active September 30, 2024 09:21
C# Create Shapes in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Initialize a new word document with the default template
var doc = new FileFormat.Words.Document();
System.Console.WriteLine("Word Document with default template initialized");
// Initialize the body with the new document
var body = new FileFormat.Words.Body(doc);
System.Console.WriteLine("Body of the Word Document initialized");
@fileformat-words-gists
fileformat-words-gists / Modify-Multiple-Frame-Paragraphs.cs
Created July 9, 2024 18:04
C# Modify Multiple Frame 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($"WordParagraphsFrame.docx");
var body = new FileFormat.Words.Body(doc);
foreach (var paragraph in body.Paragraphs)
{
if (paragraph.ParagraphBorder.Size > 0)
{
@fileformat-words-gists
fileformat-words-gists / Read-Multiple-Frame-Paragraphs.cs
Created July 9, 2024 18:00
C# Read Multiple Frame 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($"WordParagraphsFrame.docx");
var body = new FileFormat.Words.Body(doc);
// Traverse and display paragraphs with plain text
foreach (var paragraph in body.Paragraphs)
{
System.Console.WriteLine($" Paragraph Text: {paragraph.Text}");
@fileformat-words-gists
fileformat-words-gists / Create-Multiple-Frame-Paragraphs.cs
Created July 9, 2024 17:57
C# Create Multiple Frame Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Initialize a new word document with the default template
var doc = new FileFormat.Words.Document();
System.Console.WriteLine("Word Document with default template initialized");
// Initialize the body with the new document
var body = new FileFormat.Words.Body(doc);
System.Console.WriteLine("Body of the Word Document initialized");
@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)
{