把上图红色字体居中设置大小粗体,其余的不变,请各位大侠指点Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document document = wordApp.Documents.Add(ref none, ref none, ref none, ref none); 
wordApp.Application.Selection.Font.Size=40;//用这句话设置字体,使整个文档的字体都是40
wordApp.Application.Selection.ParagraphFormat.Alignment=WdParagraphAlignment.wdAlignParagraphCenter;
wordApp.Application.Selection.TypeText(deviceName + "参数设置");
wordApp.Application.Selection.TypeParagraph();
Table table1 = document.Tables.Add(document.Paragraphs.Last.Range, 36, 6, ref none, ref none);
table1.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphThaiJustify;//设置对其方式                 
table1.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;//设置表格边框样式
table1.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;//设置表格边框样式C#word

解决方案 »

  1.   

    这么说吧 用微软的这个组件设置的样式经常没用;
    这个我以前做过;
    推荐用字符串堆表的方式,写;
    就是网页的形式,html;
    html的样式,word可以识别;
      

  2.   

    我用的是winform ,winform不能用html吧!
      

  3.   

    document居中能实现,但是字体大小我找不到用哪个
      

  4.   

    能用吧,看过有在winform用html的,反正当时我设置样式,怎么都无果,最后这么解决
      

  5.   


    winform可以的,,
    而且速度很快http://blog.csdn.net/happy09li/article/details/8637039
      

  6.   

    谢谢哦!这段时间把这个问题丢到一边去了,所以就没怎么关注这个提问了,嗯,知道怎么弄了,但是我如果要改成Html的话需要很多时间,现在没时间修改了,如果以后还需要导成Word我就用这方法。
      

  7.   

    我还没有解决,把这个问题丢到一边去了,上面有说可以用Html能实现,我也看了代码,可以我现在没时间把它改成Html了,只能在原来的代码里面改,这样缩短时间一些,楼楼你回家给我查查吧!谢谢啊!
      

  8.   


    我这有js调用word.application的一些东西,希望对你有帮助var wrd=new ActiveXObject('Word.Application');
         var doc=wrd.Documents.Add("",0,0,false);//两个0为word保存的类型为word默认类型;false是不打开word直接保存,如果打开,要注意WINWORD.exe进程问题
         var Range=doc.Range();//得到整个文档编辑区域
    Range.text = dept_MC+"日常信息统计\r\n";
         Range.Font.Size=20;//设置此行字体为20
         Range.Font.Name="宋体";
         //Range.Font.spacing=40;//设置文字间宽度(空格)
         Range.ParagraphFormat.Alignment=1;//1:居中,2:居右,3:居左