yazanpro
yazanpro

Reputation: 4762

C# OpenXML (Word) Table AutoFit to Window

Open a Word (2007/2010) document that has a table in it, select the table and right click, select AutoFit-->AutoFit to Window

How can I implement this action in C# using the OpenXML SDK 2.5?

Upvotes: 12

Views: 9138

Answers (1)

Rubixus
Rubixus

Reputation: 767

You can set the width of the table to 100% of the page, or 5000 fiftieths-of-a-percent.

Table table = ...

TableWidth width = table.GetDescendents<TableWidth>().First();
width.Width = "5000";
width.Type = TableWidthUnitValues.Pct;

Upvotes: 21

Related Questions