public void putword(Microsoft.Office.Interop.Word._Application wordApp, Microsoft.Office.Interop.Word._Document wordDoc, CatagoryInfoObj obj, Object Nothing)
{
foreach (DataInfoObj c in obj.attributes)
{
if (c.name.Equals("中文名称"))
{
string strContent;//文本内容变量
strContent = c.value + " ";
wordApp.Selection.EndKey(ref unite, ref Nothing);
wordApp.Selection.Font.Bold = 0;//Bold=0为不加粗
//wordApp.Selection.Font.Name = "仿宋 GB2312";
wordApp.Selection.Font.Name = "黑体";
wordApp.Selection.Font.Name = "Times New Roman";
wordApp.Selection.Font.Size = 16;
wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;
wordApp.Selection.ParagraphFormat.LineSpacing = 12F;
wordApp.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = float.Parse("2");//首行缩进的长度
wordApp.Selection.ParagraphFormat.SpaceBefore = float.Parse("0");//段前间距
wordApp.Selection.ParagraphFormat.SpaceAfter = float.Parse("0");//段后间距
wordApp.Selection.Text = strContent;
}
if (c.name.Equals("活动简述"))
{
string strContent;//文本内容变量
strContent = c.value + " ";
wordApp.Selection.EndKey(ref unite, ref Nothing);
wordApp.Selection.Font.Bold = 0;//Bold=0为不加粗
wordApp.Selection.Font.Name = "仿宋 GB2312";
//wordApp.Selection.Font.Name = "黑体";
wordApp.Selection.Font.Name = "Times New Roman";
wordApp.Selection.Font.Size = 16;
wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;
wordApp.Selection.ParagraphFormat.LineSpacing = 12F;
wordApp.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = float.Parse("2");//首行缩进的长度
wordApp.Selection.ParagraphFormat.SpaceBefore = float.Parse("0");//段前间距
wordApp.Selection.ParagraphFormat.SpaceAfter = float.Parse("0");//段后间距
wordApp.Selection.Text = strContent;
}
自己解决了,只需将wordApp.Selection.Text = strContent;写到wordApp.Selection.EndKey(ref unite, ref Nothing);后面即可