日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

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

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

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

 
 
 
  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應(yīng)用程序  
  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)容和實(shí)現(xiàn)實(shí)例就向你介紹到這里,希望對你了解和學(xué)習(xí)C#創(chuàng)建Word文檔有所幫助。

【編輯推薦】

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

網(wǎng)站標(biāo)題:C#創(chuàng)建Word文檔實(shí)例解析
URL地址:http://www.5511xx.com/article/djehjop.html