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 Label文档,如何将数据输入到文档中?有人能给我一个这样的例子吗?
由于
答案 0 :(得分: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/