算不了。使用c#在word文档的页面中的行 [英] Count no. of lines in a page of a word document using c#

查看:107
本文介绍了算不了。使用c#在word文档的页面中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c#计算word文档特定页面中的行数。

假设我有一个word文档。我想在第3页中不计算任何行数。我该怎么做?

I want to count no of lines in a particular page of a word document using c#.
Suppose I have a word document. I want to count no of lines in the 3rd page. How shall i do it?

推荐答案

理查德是正确的:没有线的概念(...) 。有段落的概念!

看看这里: WD2000:宏来计算段落和行数文档 [ ^ ]



如果你想在单页上计算段落,你需要先选择它(因为没有功能来获取这部分信息)然后你需要使用选择对象(范围类型)以阅读此类信息。





更多:

如何从Word中的整个文档中选择当前页面 [ ^ ]

选择或引用Word对象模型中的页面 [ ^ ]
Richard is right in one point: "There is no concept of lines (...)". There is concept of paragraphs!
Have a look here: WD2000: Macro to Count Number of Paragraphs and Lines in a Document[^]

If you want to count paragraphs on single page, you need to select it first (because the is no functionality to get this portion of information) then you need to use Selection object (Range type) to read this kind of information.


More:
How to select the current page from whole document in Word[^]
Selecting or referring to a page in the Word object model[^]


文档没有概念直到它在页面上排列并且在页眉,页脚和侧边距内调整文本。因此,除非您可以为整个文档执行此操作,否则您无法知道第三页实际开始和结束的位置。我不确定Word是否将此信息保存在文档中,但您可以查看页面界面 [ ^ ]。
A document has no concept of lines until it is laid out on the page and the text adjusted within the header, footer and side margins. So unless you can do that for the entire document you have no way of knowing where the third page actually starts and ends. I am not sure whether Word saves this information in the document, but you could take a look at the Page interface[^].


这篇关于算不了。使用c#在word文档的页面中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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