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=& ...
随机推荐
- Extjs Vbox布局方式,以及align种类,flex,pack属性含义简介
VBox布局方式,熟悉下一下几个主要属性: 一.align:字符类型,指示组件在容器内的对齐方式.这个是基于容器的左上角来排列的.pack不同,pack是根据容器的最上边来显示的. 1.left(默认 ...
- iOS - 上架的APP 生成二维码下载
1.首先打开苹果App Store商店进入到里面,找到需要打开链接地址的应用程序,例如:百度. 2. 在App Store商店里面先点击一下应用程序图标,再按一下…分享按钮. 3. 接着选择分享APP ...
- [leetcode]143. Reorder List重排链表
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not mod ...
- jquery源码学习-初始(1)
最近几天一直在研究jquery源码,由于水平太低看得昏头转向.本来理解的也不是很深刻,下面就用自己的想法来说下jquery是如何定义构造函数初始化的.如果有什么不对的地方,希望个位高手指出. 首先要了 ...
- advance shading——菲涅耳现象
(计算光照的时候,从两点出发考虑,光的传播方向,以及光的在这个方向上的能量.) 光与表面交互的模型包含两类:和物体表面(surface)以及和物体的内部(body).而subsurface指的是在物体 ...
- [Selenium]Eclipse hangs at 57% in debug mode with TestNG tests
案例1: I am very thankful to saish and cbeust for the solution. I went through the similar issue with ...
- 硬件GPIO,UART,I2C,SPI电路图
- Eclipse 中 Could not find *.apk的解决方案
Eclipse 中 Could not find *.apk的解决方案 有时候debug的时候出现Could not find *.apk 特别是导入别人的例子的时候 1.选择properties-& ...
- 2018.09.12 poj2376Cleaning Shifts(线段树+简单dp)
传送门 貌似贪心能过啊%%%. 本蒟蒻写的线段树优化dp. 式子很好推啊. f[i]表示覆盖1~i所需的最小代价. 那么显然对于一个区间[li,ri]" role="present ...
- 改变yii2 $form最外层div样式
<?php $form = ActiveForm::begin([ 'options'=>['class' => 'form-horizontal row-border','enct ...