c#获取word文件页数、字数
引用命名空间:using Microsoft.Office.Interop.Word;
//启动Word程序
Application myWordApp = new ApplicationClass();
object oMissing = Missing.Value;
object Nothing = Missing.Value;
object filePath = "/upload/123.docx"; //这里是Word文件的路径
filePath = Server.MapPath(filePath.ToString()); //word物理路径 //打开文件
Document myWordDoc = myWordApp.Documents.Open(
ref filePath, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing); //文件页数
int pageNum = myWordDoc.ComputeStatistics(WdStatistic.wdStatisticPages, ref Nothing);
//文件字数
int wordNum = myWordDoc.Characters.Count; //关闭文件
myWordDoc.Close(ref oMissing, ref oMissing, ref oMissing);
//退出Word程序
myWordApp.Quit(ref Nothing, ref Nothing, ref Nothing); Response.Write("文件页数:" + pageNum + "<br/>文件字数:" + wordNum);
c#获取word文件页数、字数的更多相关文章
- c#获取pdf文件页数
引用命名空间:using iTextSharp.text.pdf; string filePath = Server.MapPath("/upload/123.pdf"); //文 ...
- JMeter获取CSV文件行数
import java.io.BufferedReader; import java.io.FileReader; BufferedReader br=new BufferedReader(new F ...
- 20171024xlVBA批量获取PPT\WORD\PDF页数
Public Sub ModifyFileNames() Dim FolderPath As String Dim FileNames As Variant Dim dotPos As Long Di ...
- iTextSharp之pdfRead(两个文件文本内容的比较,指定页数的pdf截取,水印的添加)
using iTextSharp.text; using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System; us ...
- [转载]JAVA获取word表格中数据的方案
上一个项目的开发中需要实现从word中读取表格数据的功能,在JAVA社区搜索了很多资料,终于找到了两个相对最佳的方案,因为也得到了不少网友们的帮助,所以不敢独自享用,在此做一个分享. 两个方案分别是: ...
- [原创]JAVA获取word表格中数据的方案
上一个项目的开发中需要实现从word中读取表格数据的功能,在JAVA社区搜索了很多资料,终于找到了两个相对最佳的方案,因为也得到了不少网友们的帮助,所以不敢独自享用,在此做一个分享. 两个方案分别是: ...
- python爬虫获取下一页
from time import sleep import faker import requests from lxml import etree fake = faker.Faker() base ...
- dotnet获取PDF文件的页数
#region 获取PDF文件的页数 private int BytesLastIndexOf(Byte[] buffer, int length, string Search) { if (buff ...
- [开发笔记]-C#获取pdf文档的页数
[操作pdf文档]之C#判断pdf文档的页数: /// <summary> /// 获取pdf文档的页数 /// </summary> /// <param name=& ...
随机推荐
- HashCode的理解
一.hashcode是什么 要理解hashcode首先要理解hash表这个概念 1. 哈希表 hash表也称散列表(Hash table),是根据关键码值(Key value)而直接进行访问的数据结构 ...
- Array Product(模拟)
Array Product http://codeforces.com/problemset/problem/1042/C You are given an array aa consisting o ...
- 使用HttpModule实现网址重写
1. 修改配置文件: <httpModules> <</span>add name="html" type="HttpModule&quo ...
- android:cmd下面用adb打log
进入cmd命令行,启动adb 1.用adb打log:adb logcat 2.过滤log信息:adb logcat | findstr *** 这里的***就是你需要设置的过滤项,如myscan ...
- collections系列之Counter
collections模块中有一个叫做Counter的类,该类的作用就是计数器,Counter是对dict的加工,所有Counter继承了dict的方法 1.创建一个Counter,需要import ...
- 133克隆图 · Clone Graph
[抄题]: 克隆一张无向图,图中的每个节点包含一个 label 和一个列表 neighbors. [思维问题]: [一句话思路]: 先BFS克隆点(一个点+扩展所有邻居),再克隆邻居(一个点+扩展所有 ...
- c#中@的3种作用
以前只知道@在C#中为了写文件路径的\不要加转义符而在前面加上@标识符,没想到@还有其他的作用 1.忽略转义字符例如 string fileName = "D:\\文本文件\\text.tx ...
- struts框架值栈问题三之值栈的创建和ActionContext对象的关系
3. 问题三 : 值栈对象的创建,ValueStack 和 ActionContext 是什么关系? * 值栈对象是请求时创建的 * ActionContext是绑定到当前的线程上(一个Action访 ...
- linux下memcache安装
安装配置 1. 安装libevent # tar zxf libevent-1.4.6-stable.tar.gz # cd libevent-1.4.6-stable # ./configure # ...
- JDK 泛型之 Type
JDK 泛型之 Type 一.Type 接口 JDK 1.5 引入 Type,主要是为了泛型,没有泛型的之前,只有所谓的原始类型.此时,所有的原始类型都通过字节码文件类 Class 类进行抽象.Cla ...