zoukankan      html  css  js  c++  java
  • Docx转Doc操作(c#)

    第一次使用Microsoft.Office.Interop.Word组件,马克一下。

    private void Docx2Doc(object sourceFileName, object targetFileName)
    {
        object missingValue = System.Reflection.Missing.Value;
    
        Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
        Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(
            ref sourceFileName,
            ref missingValue, ref missingValue, ref missingValue, ref missingValue,
            ref missingValue, ref missingValue, ref missingValue, ref missingValue,
            ref missingValue, ref missingValue, ref missingValue, ref missingValue,
            ref missingValue, ref missingValue, ref missingValue);
    
        object FileFormat = msWord.WdSaveFormat.wdFormatDocument; 
        object LockComments = false;
        object Password = missingValue;
        object AddToRecentFiles = false;
        object WritePassword = missingValue;
        object ReadOnlyRecommended = false;
        object EmbedTrueTypeFonts = true;
        object SaveNativePictureFormat = missingValue;
        object SaveFormsData = missingValue;
        object SaveAsAOCELetter = missingValue;
        object Encoding = missingValue;
        object InsertLineBreaks = missingValue;
        object AllowSubstitutions = missingValue;
        object LineEnding = missingValue;
        object AddBiDiMarks = missingValue;
        object CompatibilityMode = missingValue;
    
        doc.SaveAs(ref targetFileName, ref FileFormat,
            ref LockComments, ref Password, ref AddToRecentFiles, ref WritePassword,
            ref ReadOnlyRecommended, ref EmbedTrueTypeFonts, ref SaveNativePictureFormat, ref SaveFormsData,
            ref SaveAsAOCELetter, ref Encoding, ref InsertLineBreaks, ref AllowSubstitutions,
            ref LineEnding, ref AddBiDiMarks);
    
        //doc.SaveAs(ref targetFileName, ref FileFormat, 
        //        ref MissingValue, ref MissingValue, ref MissingValue, ref MissingValue, 
        //        ref MissingValue, ref MissingValue, ref MissingValue, ref MissingValue, 
        //        ref MissingValue, ref MissingValue, ref MissingValue, ref MissingValue, 
        //        ref MissingValue, ref MissingValue);
    
    
        wordApp.Documents.Close(ref missingValue, ref missingValue, ref missingValue);
    
        //关闭进程
        object saveOption = msWord.WdSaveOptions.wdDoNotSaveChanges;
        wordApp.Application.Quit(ref saveOption, ref missingValue, ref missingValue);
    }
    
  • 相关阅读:
    fir.im Weekly
    【转】UITextView的使用详解
    UITextView textViewShouldEndEditing
    【转】 iOS 两种方法实现左右滑动出现侧边菜单栏 slide view
    【转】 UITableView 的indexPath
    【转】 iOS Provisioning Profile(Certificate)与Code Signing详解
    【原】AVAudio录制,播放 (解决真机播放音量太小)
    iOS开发知识点:理解assign,copy,retain变strong
    【转】 NSArray copy 问题
    UITableView中的visibleCells的用法(visibleCells帮上大忙了)
  • 原文地址:https://www.cnblogs.com/shijun/p/2863022.html
Copyright © 2011-2022 走看看