简体   繁体   English

C#OpenXML(Word)表AutoFit到Window

[英]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 打开一个包含表格的Word(2007/2010)文档,选择表格并右键单击,选择AutoFit - > AutoFit to Window

How can I implement this action in C# using the OpenXML SDK 2.5? 如何使用OpenXML SDK 2.5在C#中实现此操作?

You can set the width of the table to 100% of the page, or 5000 fiftieths-of-a-percent. 您可以将表格的宽度设置为页面的100%,或5000个百分之五十的百分比。

Table table = ...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM