1.制作一个Word模板
{0},{1},{2}
2.编码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;
using System.Windows.Forms;
namespace ConcreteDispatch
{
class WordFormatPrint
{
private Microsoft.Office.Interop.Word.Application app = null;
/// <summary>
/// Word文本替换
/// </summary>
/// <param name="doc">文档</param>
/// <param name="args">要替换的内容</param>
internal void ReplaceWord(Document doc, params object[] args)
{
try
{
object first = 0;
object last = doc.Characters.Count;
Range range = doc.Range(ref first, ref last);
Microsoft.Office.Interop.Word.Find finder = range.Find;
finder.ClearFormatting();
object missingValue = Type.Missing;
object replaceArea = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
int i = 0;
foreach (object item in args)
{