Skip to content

Instantly share code, notes, and snippets.

@openize-words-gists
Created May 22, 2024 13:07
Show Gist options
  • Save openize-words-gists/7f2d897e587120db72d4ea7f5e41b193 to your computer and use it in GitHub Desktop.
Save openize-words-gists/7f2d897e587120db72d4ea7f5e41b193 to your computer and use it in GitHub Desktop.
C# Modify Words Document Tables
// 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