C# Microsoft.Office.Interop.Word怎么获取页数和字数

C# Microsoft.Office.Interop.Word怎么获取页数和字数,第1张

using MSWord = MicrosoftOfficeInteropWord;

//方法内容

private MSWordApplication wordApp; //Word应用程序变量

private MSWordDocument wordDoc;

//Word文档变量

private Object Nothing = MissingValue;

//初始化

wordApp = new MSWordApplicationClass();

wordDoc = wordAppDocumentsAdd(ref Nothing, ref Nothing, ref Nothing, ref Nothing);

// 打开Word

object FileName = strPath;

object readOnly = false;

object isVisible = true;

wordDoc = wordAppDocumentsOpen(ref FileName, ref Nothing, ref readOnly,

ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,

ref Nothing, ref Nothing, ref Nothing, ref isVisible, ref Nothing,

ref Nothing, ref Nothing, ref Nothing);

// 计算Word文档页数

MSWordWdStatistic stat = MSWordWdStatisticwdStatisticPages;

int num = wordDocComputeStatistics(stat, ref Nothing);

int wordNum=wordDocCharactersCount;//文档字数

XWPFDocument docx = new XWPFDocument(POIXMLDocumentopenPackage(电月度例会会议纪要docx));int pages = docxgetProperties()getExtendedProperties()getUnderlyingProperties()getPages();//总页数int wordCount = docxgetProperties()getExtendedProperties()getUnderlyingProperties()getCharacters();// 忽略空格的总字符数 另外还有getCharactersWithSpaces()方法获取带空格的总字数。Systemoutprintln (pages= + pages + wordCount= + wordCount);}public static void parse97() throws Exception {WordExtractor doc = new WordExtractor(new FileInputStream(电月度例会会议纪要doc));

以上就是关于C# Microsoft.Office.Interop.Word怎么获取页数和字数全部的内容,包括:C# Microsoft.Office.Interop.Word怎么获取页数和字数、java如何获取word文档页数、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9602703.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存