Right-to-left text in Excel files using C# and VB.NET

The following example shows how you can convert an Excel workbook with right-to-left text to PDF and other supported file formats, using the GemBox.Spreadsheet library in C# and VB.NET.

Upload your file (Drag file here)
using GemBox.Spreadsheet;

// If using the Professional version, put your serial key below.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

var workbook = ExcelFile.Load("RightToLeft.xlsx");
var worksheet = workbook.Worksheets[0];

// Show columns from the right side of the page.
worksheet.ViewOptions.ShowColumnsFromRightToLeft = true;

worksheet.Cells["A8"].Value = "200 جديدة";
// Set the reading order of the cell as right-to-left.
worksheet.Cells["A8"].Style.TextDirection = TextDirection.RightToLeft;

workbook.Save("RightToLeft.pdf");
Imports GemBox.Spreadsheet

Module Program

Sub Main()

' If using the Professional version, put your serial key below.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

Dim workbook = ExcelFile.Load("RightToLeft.xlsx")
Dim worksheet = workbook.Worksheets(0)

' Show columns from the right side of the page.
worksheet.ViewOptions.ShowColumnsFromRightToLeft = true

worksheet.Cells("A8").Value = "200 جديدة"
' Set the reading order of the cell as right-to-left.
worksheet.Cells("A8").Style.TextDirection = TextDirection.RightToLeft

workbook.Save("RightToLeft.pdf")
End Sub

End Module
Screenshot of a PDF converted from an Excel file with right-to-left text, done in C#
Screenshot of a PDF converted from an Excel file with RTL text, done in C#

You can use the CellStyle.TextDirection property to specify the reading order of a cell or the ExcelViewOptions.ShowColumnsFromRightToLeft property to specify the direction of the worksheet.

GemBox.Spreadsheet supports working with workbooks that contain bidirectional texts (languages that use a right-to-left script, such as Arabic, Persian, Urdu, Hebrew, or Yiddish) in XLSX, XLS, PDF, XPS, and image file formats.

Next steps

GemBox.Spreadsheet is a .NET library that enables you to read, write, edit, convert, and print spreadsheet files from your .NET applications using one simple API.