次のように、テンプレートからドキュメントを作成できます。
priavte void CreateWordDocument(string InputFileNamePath, string OutputFileNamePath)
{
Application app = new Microsoft.Office.Interop.Word.Application();
doc = app.Documents.Open(InputFileNamePath,ref missing, ref missing,ref Missing, ref Missing);
// Activate document
doc.Actiavte();
//Find place holders in input template and replace them with database values
this.FindAndReplace(app,"<Name>","John"); //take all values from database
this.FindAndReplace(app,"<Address>","Test address");
this.FindAndReplace(app,"<City>","Test City");
//Save file
doc.SaveAs(ref OutputFileNamePath, ref missing, ref missing, ref missing, ref missing);
doc.Close(ref missing,ref missing,ref missing,)
}
詳細については、リンクにアクセスしてください:http ://www.techrepublic.com/blog/howdoi/how-do-i-modify-word-documents-using-c/190