C# 寫入Word

世紀緣發表於2017-01-13
            Word.Application application = new Word.Application();
            Word.Document doc = application.Documents.Add();
            doc.Paragraphs.Last.Range.Font.Bold = 1;
            doc.Paragraphs.Last.Range.Font.Size = 32;
            doc.Paragraphs.Last.Range.Font.Name = "黑體";
            
            doc.Paragraphs.Last.Range.Text = "這是第一行\n";
            doc.Paragraphs.Last.Range.Font.Bold = 0;
            doc.Paragraphs.Last.Range.Font.Size = 12;
            doc.Paragraphs.Last.Range.Font.Name = "新宋體";
            doc.Paragraphs.Last.Range.Text = "第二行開始了";
            doc.Paragraphs.Last.Range.Text = "會覆蓋的";
            doc.Paragraphs.Last.Range.Text += "不會覆蓋的";
            doc.Paragraphs.Last.Range.InsertAfter("這是後面的內容");

相關文章