偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

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

開(kāi)發(fā) 后端
C#創(chuàng)建Word文檔的具體實(shí)現(xiàn)是怎么樣子的呢?C#創(chuàng)建Word文檔需要用到什么方法呢?那么本文就向你介紹具體的實(shí)例實(shí)現(xiàn),希望對(duì)你的學(xué)習(xí)有所幫助。

C#創(chuàng)建Word文檔是我們經(jīng)常在實(shí)際開(kāi)發(fā)應(yīng)用中碰到的實(shí)用性開(kāi)發(fā)實(shí)例,那么具體的實(shí)現(xiàn)過(guò)程是什么呢?我們下面通過(guò)一個(gè)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í)例就向你介紹到這里,希望對(duì)你了解和學(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#打開(kāi)Word文檔實(shí)例
  5. 淺析C#Word文檔替換操作
責(zé)任編輯:仲衡 來(lái)源: CSDN博客
相關(guān)推薦

2009-08-28 17:34:14

讀取word文檔

2009-09-01 13:13:28

C#打開(kāi)Word文檔

2009-08-28 17:46:18

C#讀取Word文檔

2009-09-02 16:14:21

C#動(dòng)態(tài)創(chuàng)建數(shù)組

2009-08-19 10:16:15

C#操作Word

2009-09-09 14:40:15

C# XML解析

2009-08-19 09:42:52

C#操作Word書(shū)簽

2009-09-01 11:25:08

C#讀取Word文件

2009-08-19 11:13:49

C#操作Word

2009-08-19 11:34:06

C#操作Word

2009-08-18 10:47:40

C#枚舉類(lèi)型

2009-09-09 13:57:28

C# XML解析

2009-08-24 17:24:28

C#創(chuàng)建XML文檔

2009-09-07 06:31:32

C#窗體移動(dòng)

2009-08-26 12:14:44

C#打印設(shè)置

2009-08-31 18:17:32

C#接口編程

2009-08-19 16:09:15

C#操作Access

2009-08-12 15:26:38

C#讀取XML文檔

2009-08-26 11:32:37

C#打印文檔

2009-08-19 10:46:48

C#操作Word表格
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)