Right-to-Left Text

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 component in C# and VB.NET.

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

class Program
{
    static void Main()
    {
        // If using the Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        var workbook = ExcelFile.Load("%InputFileName%");
        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.%OutputFileType%");
    }
}
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("%InputFileName%")
        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.%OutputFileType%")
    End Sub

End Module
Converted PDF with bidiretional text
Screenshot of converted PDF

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.

See also


Next steps

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

Download Buy