使用 VSTO 删除 Word 2007 中段落后的间距
我正在用 C# 创建并填充 Word 2007 表。当我在 Word 中查看结果时,每个单元格的文本后面都附加了额外的垂直空间。在Word中可以通过“页面布局”/段落/间距来调整,其中初始值为10pt。
---------------------------------------------------
| Text... | Text.... | More text... |
| | | | <- Extra spacing
---------------------------------------------------
| | | |
如何使用 VSTO 更改此设置?
我尝试录制一个宏,希望在VB代码中得到一些答案 - 它似乎没有响应间距值的变化。
我在 MSDN 上的 VSTO 文档中找不到任何相关内容。
编辑: 使用 Word 模板,我可以标记要填充的区域并将间距设置为 0。然后它会通过我的表格继承 - 因此它现在可以使用。不过,如果能够通过 C# 控制间距而不依赖于 Word 中的继承,那就太好了。
I am creating and populating a Word 2007 table in C#. When I view the result in Word, each cell has extra vertical space appended after the text. In Word this can be adjusted through the "page layout"/Paragraph/Spacing, where the initial value is 10pt.
---------------------------------------------------
| Text... | Text.... | More text... |
| | | | <- Extra spacing
---------------------------------------------------
| | | |
How can this be changed using VSTO?
I have tried to record a macro, hoping for some answers in the VB code - it didn't seem to respond to the changing of the spacing value.
I haven't been able to find anything related in the VSTO documentation on MSDN.
Edit:
Using a Word template, I can mark the area I'm populating and set the spacing to 0. It is then inherited through my table - thus it works for now. But still, it would be nice to be able to control the spacing from C# and not rely on inheritance in Word.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 Jose Anton Bautista 的说法,解决方案如下所示:
或者
这非常有效,对我来说,它显示了我还可以访问文档元素的各种属性的位置。
According to Jose Anton Bautista the solution is like the following:
Or
This works very well and to me, it shows where I also can access various properties of the document elements.
我使用内置样式“表格网格”来删除单元格中的段落间距样式(Word 2007 默认情况下,“插入”>“表格”使用相同的样式):
I've used the built-in style "Table Grid" to remove the paragraph spacing style in the cells (The Word 2007 default, Insert > Table uses the same style):
您还可能需要设置
LineSpacingRule
Also you may need to set
LineSpacingRule