2012-06-28 22 views
5

Tôi tạo tài liệu từ bằng C# với Microsoft.Office.Interop.WordLàm thế nào tôi có thể đặt hướng văn bản RightToLeft trong tài liệu từ ms trong C#?

Tôi muốn hiển thị văn bản tiếng Ả Rập theo hướng rtl (RightToLeft). Làm thế nào tôi có thể thiết lập hướng văn bản để rtl?

Trong mã dưới đây của tôi, tôi thay đổi Alighnment, Nhưng tôi không thể thay đổi hướng. Làm ơn giúp tôi!

Word.Application wordApp = new Word.Application(); 
object objMissing = System.Reflection.Missing.Value; 
Word.Document wordDoc = wordApp.Documents.Add(ref objMissing, ref objMissing, ref objMissing, ref objMissing); 
Word.Paragraph wordParagraph = wordDoc.Paragraphs.Add(ref objMissing); 
wordParagraph.Range.Font.Name = "B Titr"; 
wordParagraph.Range.Font.Size = 14; 
WordParagraph.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight; 
wordParagraph.Range.Text = "My Arabic text"; 
wordParagraph.Range.InsertParagraphAfter(); 

Trả lời

4

Bạn đã thử cái này chưa?

wordParagraph.ReadingOrder = WdReadingOrder.wdReadingOrderRtl; 
+0

Vâng, nhưng nó vẫn LeftToRight! –

+0

@ a_ahmadi: tôi có cùng một vấn đề, bạn có tìm được giải pháp không? –

+0

Tôi sử dụng điều này: wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight; –

4

Hãy thử

oDoc.Paragraphs.ReadingOrder = Word.WdReadingOrder.wdReadingOrderRtl; 

nơi oDoc là một trường hợp Word._Document

Các vấn đề liên quan