页数的正则表达式 [英] Regular Expression for page counts

查看:166
本文介绍了页数的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人对word文档中的页数有任何想法吗?像pdf一样可以使用...

Does anyone have any idea on how to do a page count on a word document.Like for pdf this will work...

using (StreamReader sr = new StreamReader(File.OpenRead(fileName)))
       {
           Regex regex = new Regex(@"/Type\s*/Page[^s]");
           MatchCollection matches = regex.Matches(sr.ReadToEnd());

           return matches.Count;
       }


在计算文档中的页数时,任何用于工作或excel文档的表达式


Any expression for work or excel document on counting the number of pages in a document

推荐答案

我知道Microsoft Word API中提供了统计API来获取答案;然后我立即找到此CodeProject解决方案:
对MS Word文档中的页面进行计数 [
I knew there is the statistics API in Microsoft Word API to get the answer; and then I immediately found this CodeProject solution:
Count pages in MS Word Document[^].

This is all you need.

Good luck,
—SA


这篇关于页数的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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