重慶分公司,新征程啟航
為企業(yè)提供網站建設、域名注冊、服務器等服務
為企業(yè)提供網站建設、域名注冊、服務器等服務
C#中怎么創(chuàng)建一個Word文檔,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
為邵東等地區(qū)用戶提供了全套網頁設計制作服務,及邵東網站建設行業(yè)解決方案。主營業(yè)務為成都網站設計、成都網站建設、外貿網站建設、邵東網站設計,以傳統(tǒng)方式定制建設網站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
C#創(chuàng)建Word文檔實例:
using MSExcel = Microsoft.Office.Interop.Excel; using System.IO; using System.Refletion; //C#創(chuàng)建Word文檔 Class Program { static void Main(string[] args) { string path; //C#創(chuàng)建Word文檔之文件路徑 string strContent;//文本內容 MSWord.Application wordApp;提要 //C#創(chuàng)建Word文檔之word應用程序 MSWord.document wordDoc;//word文檔 path = @"c:\test.docx"; wordApp = new MSWord.applicationClass(); if(File.Exists(path)) { File.Delete(path); } Object nothing = Missing.Value; wordDoc = wordApp.Documents.Add( ref nothing,ref nothing,ref nothing,ref nothing); strContent = "你好!\n"; wordDoc.Paragraphs.Last.Rang.Text = strContent; object format = MSWord.WdSaveFormat.wdFormatDocumentDefault; wordDoc.SaveAs(ref path,ref format, ref nothing,ref nothing,ref nothing, ref nothing,ref nothing, ref nothing,ref nothing,ref nothing, ref nothing,ref nothing,ref nothing, ref nothing,ref nothing,ref nothing); wordDoc.Close(ref nothing,ref nothing,ref nothing); wordApp.Quit(ref nothing,ref nothing,ref nothing); } //C#創(chuàng)建Word文檔 }
看完上述內容,你們掌握C#中怎么創(chuàng)建一個Word文檔的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!