Interop.Word不适用于阿拉伯文本

时间:2013-09-07 07:23:52

标签: c# unicode ms-word interop arabic

我正在尝试使用C#.net创建一个word文档,我所做的就是使用这个代码使用Interop.Word:

object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ 

//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
    ref oMissing, ref oMissing);

//Insert a paragraph at the beginning of the document.
Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = "Heading 1";
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24;    //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter();

//Insert a paragraph at the end of the document.
Word.Paragraph oPara2;
object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara2.Range.Text = "Heading 2";
oPara2.Format.SpaceAfter = 6;
oPara2.Range.InsertParagraphAfter();

一切正常,但我的文字是阿拉伯语并设置为oPara1.Range.Font.Bold = 1;不起作用也改变字体名称

你能否弄清楚为什么会遇到这种麻烦?我该如何解决?

1 个答案:

答案 0 :(得分:1)

上述评论中写的nagham_4ng解决方案是在适当情况下使用Font.NameBiFont.BoldBi属性,而不是Font.NameFont.Bold