C# OpenXML (Word) Table AutoFit to Window
Asked Answered
S

1

12

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?

Sophomore answered 2/8, 2013 at 20:13 Comment(1)
I already tried to use the productivity tool with no luck.Sophomore
M
21

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;
Marcelinomarcell answered 2/8, 2013 at 20:59 Comment(1)
5000 fiftieths-of-a-percent 🦧Tirade

© 2022 - 2024 — McMap. All rights reserved.