This project has moved. For the latest updates, please go here.

TextDirection in cell

Dec 17, 2012 at 8:41 AM


Is there a way to change the text direction for a cell to RTL?

The default is 'context' and it is working ok, as much as I can see, but is there a way to control the value for text direction (between LTR, RTL)?

many thanks.

Dec 19, 2012 at 11:32 AM
Edited Dec 19, 2012 at 11:34 AM

Use  TextRotation Property of Style to set particular angle.

using (ExcelRange verticalTitle = a_worksheet.Cells[fromRow,1,toRow,1])
                verticalTitle.Merge = true;
                verticalTitle.Style.Font.Size = 18;
                verticalTitle.Style.Font.Bold = true;
                verticalTitle.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                verticalTitle.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
                verticalTitle.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                verticalTitle.Style.TextRotation = 90;
                verticalTitle.Value = m_model.Name;

One thing to notice is the fact that alignment has to be made before setting TextRotation. I don't know why this dependency exists it might be a bug, but it exists. So, first set alignment if needed and then set TextRotation.

Dec 19, 2012 at 2:31 PM


Thanks for the answer, but I'm not looking for text rotation. I'm looking for text direction, like in Hebrew, when the text goes from right-to-left, instead of the default left-to-right.

Dec 20, 2012 at 10:50 AM
Edited Dec 20, 2012 at 10:54 AM

So, there are two threads which you might be interested in.


using (ExcelRange someRange = a_worksheet.Cells[fromRow,fromCol,toRow,toCol])
someRange.Style.ReadingOrder = ExcelReadingOrder.RightToLeft;
} <--  (above mentioned seems to not work properly however you might check it by yourself)

You may also be interested in changing layout to RightToLeft which will cause that  CELLS numeration will start from right upper corner.

a_worksheet.View.RightToLeft = true; <-- This one works well.




Dec 20, 2012 at 12:03 PM

Thanks. The first example is exactly what I was looking for.

Dec 20, 2012 at 2:03 PM

btw, does it work for you ?

Dec 20, 2012 at 2:28 PM


Yes, I forgot to mention.

someRange.Style.ReadingOrder = ExcelReadingOrder.RightToLeft;

This property works fine.

Dec 20, 2012 at 4:14 PM

Strange, because it didnt work for me.