foreach (DataInfoObj c in obj.attributes)
{
if (c.name.Equals("中文名称"))
{
string strContent;//文本内容变量
strContent = " " + c.value + " ";
//wordApp.Selection.EndKey(ref unite, ref Nothing);
wordDoc.Paragraphs.Last.Range.Font.Bold = 0;//Bold=0为不加粗
wordDoc.Paragraphs.Last.Range.Font.Name = "黑体";
wordDoc.Paragraphs.Last.Range.Font.NameOther = "Times New Roman";
wordDoc.Paragraphs.Last.Range.Font.Size = 16F;
wordDoc.Paragraphs.Last.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;
wordDoc.Paragraphs.Last.Range.ParagraphFormat.LineSpacing = 12F;//设置文档的行间距
//wordApp.Selection.ParagraphFormat.FirstLineIndent = 56.6;//首行缩进的长度
wordApp.CentimetersToPoints(float.Parse("56.6"));//首行缩进
wordDoc.Paragraphs.Last.SpaceBefore = float.Parse("0");//段前间距
wordDoc.Paragraphs.Last.SpaceAfter = float.Parse("0");//段后间距
wordDoc.Paragraphs.Last.Range.InsertAfter(strContent);
}
if (c.name.Equals("活动简述"))
{
string strContent;//文本内容变量
strContent = " " + c.value;
wordDoc.Paragraphs.Last.Range.Font.Bold = 0;//Bold=0为不加粗
//wordApp.Selection.EndKey(ref unite, ref Nothing);
wordDoc.Paragraphs.Last.Range.Font.Name = "仿宋 GB2312";
wordDoc.Paragraphs.Last.Range.Font.NameOther = "Times New Roman";
wordDoc.Paragraphs.Last.Range.Font.Size = 16F;
wordDoc.Paragraphs.Last.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;
wordDoc.Paragraphs.Last.Range.ParagraphFormat.LineSpacing = 12F;//设置文档的行间距
wordDoc.Paragraphs.Last.SpaceBefore = float.Parse("0");//段前间距
wordDoc.Paragraphs.Last.SpaceAfter = float.Parse("0");//段后间距
wordDoc.Paragraphs.Last.Range.InsertAfter(strContent);
}
strContent = " " + c.value + " "这句如果改成strContent = " " + c.value + "\n",那么前黑体后宋体,可是就会多一个回车符。如果不加,就会全是宋体。怎样不加"\n",也能保持前黑后宋体????小白一枚,求大神,谢谢
结贴,解决方法https://q.cnblogs.com/q/86692/