日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#創(chuàng)建Word文檔實例解析

C#創(chuàng)建Word文檔是我們經(jīng)常在實際開發(fā)應用中碰到的實用性開發(fā)實例,那么具體的實現(xiàn)過程是什么呢?我們下面通過一個C#創(chuàng)建Word文檔實例向你介紹具體的步驟。

C#創(chuàng)建Word文檔實例:

 
 
 
  1. using MSExcel = Microsoft.Office.Interop.Excel;  
  2.  
  3. using System.IO;  
  4.  
  5. using System.Refletion;  
  6. //C#創(chuàng)建Word文檔  
  7. Class Program  
  8.  
  9. {  
  10.  
  11.   static void Main(string[] args)  
  12.  
  13.   {  
  14.  
  15. string path;  //C#創(chuàng)建Word文檔之文件路徑  
  16.  
  17. string strContent;//文本內(nèi)容  
  18.  
  19. MSWord.Application wordApp;提要    
  20. //C#創(chuàng)建Word文檔之word應用程序  
  21.  
  22. MSWord.document wordDoc;//word文檔  
  23.  
  24. path = @"c:\test.docx";  
  25.  
  26. wordApp = new MSWord.applicationClass();  
  27.  
  28. if(File.Exists(path))  
  29.  
  30. {  
  31.  
  32.   File.Delete(path);  
  33.  
  34. }  
  35.  
  36. Object nothing = Missing.Value;  
  37.  
  38. wordDoc = wordApp.Documents.Add(  
  39. ref nothing,ref nothing,ref nothing,ref nothing);  
  40.  
  41. strContent = "你好!\n";  
  42.  
  43. wordDoc.Paragraphs.Last.Rang.Text = strContent;  
  44.  
  45. object format = MSWord.WdSaveFormat.wdFormatDocumentDefault;  
  46.  
  47. wordDoc.SaveAs(ref path,ref format,  
  48. ref nothing,ref nothing,ref nothing,  
  49. ref nothing,ref nothing,  
  50.  
  51.  ref nothing,ref nothing,ref nothing,  
  52. ref nothing,ref nothing,ref nothing,  
  53.  
  54. ref nothing,ref nothing,ref nothing);  
  55.  
  56. wordDoc.Close(ref nothing,ref nothing,ref nothing);  
  57.  
  58. wordApp.Quit(ref nothing,ref nothing,ref nothing);  
  59.  
  60.   }  
  61. //C#創(chuàng)建Word文檔  
  62. }   

C#創(chuàng)建Word文檔的基本內(nèi)容和實現(xiàn)實例就向你介紹到這里,希望對你了解和學習C#創(chuàng)建Word文檔有所幫助。

【編輯推薦】

  1. 詳解C#讀取word內(nèi)容操作
  2. C#讀取Word文件實例詳解
  3. C#讀取Word學習經(jīng)驗總結
  4. 淺析C#打開Word文檔實例
  5. 淺析C#Word文檔替換操作

本文名稱:C#創(chuàng)建Word文檔實例解析
轉(zhuǎn)載來源:http://www.dlmjj.cn/article/djehjop.html