如何使用DocX控制Word文档中的表格列宽? [英] How can I control table column width in Word documents using DocX?

查看:200
本文介绍了如何使用DocX控制Word文档中的表格列宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重新创建一个像这样的表:

I am trying to recreate a table like this:

我正在使用DocX库来处理Word文件,但是我无法正确设置宽度.尝试设置单元格的宽度似乎仅在未将其设置为窗口自动调整模式时才有效,并且似乎仅在指定的宽度大于表宽度的一半时才调整大小,或者说,我可以使一个单元格大于宽度的一半但不能更小.

I am using the DocX library to manipulate Word files, but I'm having trouble getting the widths right. Trying to set the widths of cells only seems to work when it's not set to the window autofit mode, and it only seems to resize when the specified width is greater than half of the table width, or rather, I can make a cell bigger than half the width but not smaller.

再现预期表的最简单方法是什么?

What would be the simplest way to reproduce the intended table?

推荐答案

我自己找到了答案.为了正确设置宽度,您必须遍历列中的每个单元格并设置每个宽度.不适用于选择的任何自动调整选项.

I found the answer to this myself. In order to properly set the width, you have to loop through each cell in a column and set every width. This will not work with any autofit options selected.

这篇关于如何使用DocX控制Word文档中的表格列宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆