C# 写入Word

            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("这是后面的内容");

你可能感兴趣的:(C#)