引用命名空间: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文件页数、字数的更多相关文章

  1. c#获取pdf文件页数

    引用命名空间:using iTextSharp.text.pdf; string filePath = Server.MapPath("/upload/123.pdf"); //文 ...

  2. JMeter获取CSV文件行数

    import java.io.BufferedReader; import java.io.FileReader; BufferedReader br=new BufferedReader(new F ...

  3. 20171024xlVBA批量获取PPT\WORD\PDF页数

    Public Sub ModifyFileNames() Dim FolderPath As String Dim FileNames As Variant Dim dotPos As Long Di ...

  4. iTextSharp之pdfRead(两个文件文本内容的比较,指定页数的pdf截取,水印的添加)

    using iTextSharp.text; using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System; us ...

  5. [转载]JAVA获取word表格中数据的方案

    上一个项目的开发中需要实现从word中读取表格数据的功能,在JAVA社区搜索了很多资料,终于找到了两个相对最佳的方案,因为也得到了不少网友们的帮助,所以不敢独自享用,在此做一个分享. 两个方案分别是: ...

  6. [原创]JAVA获取word表格中数据的方案

    上一个项目的开发中需要实现从word中读取表格数据的功能,在JAVA社区搜索了很多资料,终于找到了两个相对最佳的方案,因为也得到了不少网友们的帮助,所以不敢独自享用,在此做一个分享. 两个方案分别是: ...

  7. python爬虫获取下一页

    from time import sleep import faker import requests from lxml import etree fake = faker.Faker() base ...

  8. dotnet获取PDF文件的页数

    #region 获取PDF文件的页数 private int BytesLastIndexOf(Byte[] buffer, int length, string Search) { if (buff ...

  9. [开发笔记]-C#获取pdf文档的页数

    [操作pdf文档]之C#判断pdf文档的页数: /// <summary> /// 获取pdf文档的页数 /// </summary> /// <param name=& ...

随机推荐

  1. pymysql基本的使用方法

    1.导入模块+创建连接 import pymysql # 1.通过python去连接数据库 conn = pymysql.connect(host="127.0.0.1",port ...

  2. SqlServer 查询死锁,杀死死锁进程*转载

    原文: -- 查询死锁 select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName fro ...

  3. PHP下ajax跨域的解决方案之jsonp

    首先要说明一下json和jsonp的区别? json是一种基于文本的数据交换方式,或者叫做描述数据的一种格式. var person = { "name": "test& ...

  4. Struts2的拦截器技术

    1. 拦截器的概述 * 拦截器就是AOP(Aspect-Oriented Programming,面向切面)的一种实现.(AOP是指用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加入某些操作 ...

  5. 版本号比较函数-js

    面试前,让做的一个版本号比较函数. <script type="text/javascript"> var v1=prompt("请输入第一个版本号" ...

  6. Python图像处理库:Pillow 初级教程-乾颐堂

    Image类 Pillow中最重要的类就是Image,该类存在于同名的模块中.可以通过以下几种方式实例化:从文件中读取图片,处理其他图片得到,或者直接创建一个图片. 使用Image模块中的open函数 ...

  7. OSGi karaf scheduler

    OSGi karaf scheduler karaf 中提供了定时任务管理,只需安装 feature:install scheduler 即可,然后在 karaf 容器中发布 org.apache.k ...

  8. 连接数据库-corina

    import pymysqlimport pandas as pdfrom pandas import DataFramefrom sqlalchemy import create_engine cl ...

  9. Cookis与文件缓存的区别

    我是一位顶尖的网络专家.稍后更新...

  10. EPLAN 软件平台中的词“点“大全

    1. 中断点(Interruption Point):     在原理图绘制时,如果当前绘图区域的空间不足,需要转到其它页面继续绘制,而这两页之间存在连续的“信息流“时,可以使用“中断点“来传递这种“ ...