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=& ...
随机推荐
- DP解LCS问题模板及其优化
LCS--Longest Common Subsequence,即最长公共子序列,一般使用DP来解. 常规方法: dp[i][j]表示字符串s1前i个字符组成的字符串与s2前j个字符组成的字符串的LC ...
- SVN版本冲突问题
--------------------siwuxie095 SVN 版本冲突问题 如:Jack 和 Mary 从仓库中将项目下载到本地,然后 Jack 修改了 项目中的一个文件,并上传到仓库中,之后 ...
- maven打包部署到私服
转载地址:http://blog.csdn.net/stormragewang/article/details/43407471 心得 apache的开源maven插件对我们使用maven进行打包,发 ...
- php加速缓存器opcache,apc,xcache,eAccelerator
一.opcache opcache 通过将 PHP 脚本预编译的字节码存储到共享内存中来提升 PHP 的性能, 存储预编译字节码的好处就是 省去了每次加载和解析 PHP 脚本的开销. PHP 5. ...
- centos6.6中修改yum源
1.进入设置yum源的目录 > cd /etc/yum.repos.d 2.复制或重命名CentOS-Base.repo文件 > mv CentOS-Base.repo CentOS-Ba ...
- JsonConvert.SerializeObject 空值处理
var settings = new JsonSerializerSettings() { ContractResolver= new NullToEmptyStringResolver() }; v ...
- 构建openssl debug版
一.简介 作为一种安全协议,openssl囊括了主要的密码算法.常用的密钥和证书封装管理功能以及SSL协议,并提供了丰富的应用程序供测试或其它目的使用. 参考: http://www.linuxidc ...
- Laravel 5.4+Vue.js 初体验:Laravel下配置运行Vue.js
生产材料PHP:PHP 5.6+Laravel 5.4:https://github.com/laravel/laravel/releases/Composer:http://getcomposer. ...
- 检查Makefile中的tab
转:http://stackoverflow.com/questions/16931770/makefile4-missing-separator-stop makefile has a very s ...
- jquery插件解读之tabs
先上代码,符简略关键性说明: /** * jQuery EasyUI 1.4.1 * * Copyright (c) 2009-2014 www.jeasyui.com. All rights re ...