首页 新闻 会员 周边 捐助

c# 上面设置黑体,下面设置宋体,互不影响

0
[已关闭问题] 关闭于 2016-09-30 10:03

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",也能保持前黑后宋体????小白一枚,求大神,谢谢

life清者自清的主页 life清者自清 | 初学一级 | 园豆:76
提问于:2016-09-28 14:57
< >
分享
所有回答(1)
0

结贴,解决方法https://q.cnblogs.com/q/86692/

life清者自清 | 园豆:76 (初学一级) | 2016-09-29 17:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册