zoukankan      html  css  js  c++  java
  • [WPF]读取word文档


    //将word转换成xps
    private XpsDocument ConvertWordToXPS(string wordDocName) { FileInfo fi = new FileInfo(wordDocName); XpsDocument result = null; string xpsDocName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), fi.Name); xpsDocName = xpsDocName.Replace(".docx", ".xps").Replace(".doc", ".xps"); Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application(); try { if (!File.Exists(xpsDocName)) { wordApplication.Documents.Add(wordDocName); Microsoft.Office.Interop.Word.Document doc = wordApplication.ActiveDocument; doc.ExportAsFixedFormat(xpsDocName, WdExportFormat.wdExportFormatXPS, false, WdExportOptimizeFor.wdExportOptimizeForPrint, WdExportRange.wdExportAllDocument, 0, 0, WdExportItem.wdExportDocumentContent, true, true, WdExportCreateBookmarks.wdExportCreateHeadingBookmarks, true, true, false, Type.Missing); result = new XpsDocument(xpsDocName, System.IO.FileAccess.Read); } if (File.Exists(xpsDocName)) { result = new XpsDocument(xpsDocName, FileAccess.Read); } } catch (Exception ex) { string error = ex.Message; wordApplication.Quit(WdSaveOptions.wdDoNotSaveChanges); } wordApplication.Quit(WdSaveOptions.wdDoNotSaveChanges); return result; }
    //页面调用

    DocumentViewer docViewer = new DocumentViewer();
    docViewer.Document = new XpsDocument(("地址参数"+ ".xps"), System.IO.FileAccess.Read).GetFixedDocumentSequence();

    docViewer.FitToWidth();

     
  • 相关阅读:
    DVD X Player 5.5 PRO
    Freefloat FTP Server 1.0漏洞分析
    基于约束的SQL攻击
    Commons-Collections漏洞
    Code-Audit-Challenges-php-2
    GSM Sniffer环境--c118+osmocombb
    XXE (XML External Entity Injection) :XML外部实体注入
    hyperledger fabric学习(1)
    zero to one (4)
    zero to one (3)
  • 原文地址:https://www.cnblogs.com/wdd812674802/p/10947596.html
Copyright © 2011-2022 走看看