Created
May 22, 2024 13:07
-
-
Save openize-words-gists/7f2d897e587120db72d4ea7f5e41b193 to your computer and use it in GitHub Desktop.
C# Modify Words Document Tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>. | |
// Load the Word Document | |
var doc = new FileFormat.Words.Document($"WordTables.docx"); | |
var body = new FileFormat.Words.Body(doc); | |
var tables = body.Tables; | |
foreach (var table in tables) | |
{ | |
table.Column.Width = 2000; | |
doc.Update(table); | |
} | |
// Save the modified Word Document | |
doc.Save($"ModifiedWordTables.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment