1
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document oDocument = new Microsoft.Office.Interop.Word.Document();
oDocument = oWord.Documents.Add();
Microsoft.Office.Interop.Word.MailingLabel oLable = oWord.MailingLabel;

oDocument = oLable.CreateNewDocument();
oDocument.SaveAs(SaveFileDialog1.InitialDirectory.ToString() + SaveFileDialog1.FileName);
oWord.Quit();

我可以从上面的代码中得到一个空的 Word Lable 文档,如何将数据输入到文档中?任何人都可以给我一个这样做的例子吗?

谢谢

4

1 回答 1

0

这就是您在文件中写入内容的方式。

        Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
        Microsoft.Office.Interop.Word.Document oDocument = new Microsoft.Office.Interop.Word.Document();
        oDocument = oWord.Documents.Add();

        BigInteger r = 1;
        for (int i = 1; i <= 64; i++)
        {
            r = r * i;             
        }
        Console.Write(r.ToString());

        oDocument.Content.SetRange(0, 0);
        oDocument.Content.Text = r.ToString();

        oDocument.SaveAs(@"d:\mydoc.docx");
        oWord.Quit();

你可以在这里找到更多信息:http ://www.c-sharpcorner.com/UploadFile/muralidharan.d/how-to-create-word-document-using-C-Sharp/

于 2014-10-31T08:54:31.553 回答