We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

RightToLeft property not working in the Table class

I’m trying to use the “RightToLeft” property to set the Table’s reading direction to “Right To Left”. However, it doesn’t seem to work. Please see my complete code below and I’m using the latest version of the Slides dll (16.12). I attached two files. One is called “Aspose_Generated_RTL” which is the pptx generated by the code below. The other attached file named “Expected_RTL” which is a version that we modified to demonstrate how the table should look like in a RTL language. If you can take a look at the code and compare those two attached files, and let us know why the Tabel’s “RightToLeft” is not producing the expected result, we will really appreciate it.

using (Presentation pres = new Presentation())
{
Guid guid = Guid.NewGuid();
var tableWidth = (float)400.2;
var fontSize = (float)8;
var headerData = new string[] { “هذا هو الخلاف 1.1”, “هذا هو الخلاف1.2” };
            <span style="color:blue;">var</span> rowData = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span><<span style="color:blue;">string</span>[]>
            {
                <span style="color:blue;">new</span> []
                {
                    <span style="color:#a31515;">"كيف صف 2.1؟"</span>, <span style="color:#a31515;">"كيف صف 2.2؟"</span>
                },
                <span style="color:blue;">new</span> []
                {
                    <span style="color:#a31515;">"هذا شيء عظيم 3.1!"</span>, <span style="color:#a31515;">"هذا شيء عظيم 3.2!"</span>
                }
            };
            <span style="color:blue;">var</span> tableX = (<span style="color:blue;">float</span>)111.168;
            <span style="color:blue;">var</span> tableY = (<span style="color:blue;">float</span>)128.519928;
            <span style="color:blue;">double</span>[] rows = <span style="color:blue;">new</span> <span style="color:blue;">double</span>[] { 1 };
            <span style="color:blue;">var</span> baseColWidths = <span style="color:blue;">new</span> <span style="color:blue;">double</span>[] { (<span style="color:blue;">double</span>)tableWidth / 100 * 30, (<span style="color:blue;">double</span>)tableWidth / 100 * 30 };
            <span style="color:#2b91af;">ISlide</span> sld = pres.Slides[0];
            <span style="color:green;">//Add table shape to slide</span>
            <span style="color:#2b91af;">ITable</span> tbl = sld.Shapes.AddTable(tableX, tableY, baseColWidths.ToArray(), rows);
            <span style="background-color: rgb(255, 255, 0);">tbl.RightToLeft = <span style="color:blue;">true</span>;</span>
            <span style="color:blue;">var</span> i = 0;
            <span style="color:blue;">foreach</span> (<span style="color:blue;">var</span> header <span style="color:blue;">in</span> headerData)
            {
                <span style="color:blue;">var</span> cell = tbl.Rows[0][i];
                <span style="color:blue;">var</span> textFrame = cell.TextFrame;
                textFrame.Paragraphs.Clear();
                textFrame.Paragraphs.AddFromHtml(header);
                cell.BorderBottom.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                cell.BorderBottom.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                cell.BorderBottom.Width = 3.0;
                cell.BorderTop.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                cell.BorderTop.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                cell.BorderTop.Width = 3.0;
                cell.BorderLeft.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                cell.BorderLeft.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                cell.BorderLeft.Width = 3.0;
                cell.BorderRight.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                cell.BorderRight.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                cell.BorderRight.Width = 3.0;

                <span style="color:#2b91af;">IParagraph</span> p = textFrame.Paragraphs[0];
                p.ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                p.ParagraphFormat.DefaultPortionFormat.FontHeight = fontSize;
                p.ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Black;
                p.ParagraphFormat.Alignment = <span style="color:#2b91af;">TextAlignment</span>.Center;
                p.ParagraphFormat.DefaultPortionFormat.LatinFont = <span style="color:blue;">new</span> <span style="color:#2b91af;">FontData</span>(<span style="color:#a31515;">"Segoe UI"</span>);
                i++;
            }

            <span style="color:blue;">var</span> rowIndex = 1;
            <span style="color:blue;">foreach</span> (<span style="color:blue;">var</span> row <span style="color:blue;">in</span> rowData)
            {
                i = 0;
                <span style="color:blue;">var</span> tblRow = tbl.Rows.AddClone(tbl.Rows[0], <span style="color:blue;">false</span>)[0];
                <span style="color:blue;">foreach</span> (<span style="color:blue;">var</span> currentRowData <span style="color:blue;">in</span> row)
                {
                    <span style="color:blue;">var</span> cell = tbl.Rows[rowIndex][i];
                    <span style="color:blue;">var</span> textFrame = cell.TextFrame;
                    textFrame.Paragraphs.Clear();

                    textFrame.Paragraphs.AddFromHtml(currentRowData);
                    cell.BorderBottom.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                    cell.BorderBottom.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                    cell.BorderBottom.Width = 3.0;
                    cell.BorderTop.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                    cell.BorderTop.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                    cell.BorderTop.Width = 3.0;
                    cell.BorderLeft.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                    cell.BorderLeft.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                    cell.BorderLeft.Width = 3.0;
                    cell.BorderRight.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                    cell.BorderRight.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Gray;
                    cell.BorderRight.Width = 3.0;

                    <span style="color:#2b91af;">IParagraph</span> p = textFrame.Paragraphs[0];
                    p.ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = <span style="color:#2b91af;">FillType</span>.Solid;
                    p.ParagraphFormat.DefaultPortionFormat.FontHeight = fontSize;
                    p.ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = <span style="color:#2b91af;">Color</span>.Black;
                    p.ParagraphFormat.Alignment = <span style="color:#2b91af;">TextAlignment</span>.Left;
                    textFrame.TextFrameFormat.AnchoringType = <span style="color:#2b91af;">TextAnchorType</span>.Top;
                    textFrame.OnEachParagraph(
                        paragraph =>
                        {
                            paragraph.ParagraphFormat.MarginLeft = 15F;
                        });


                    textFrame.Paragraphs.Select(
                        paragraph =>
                            paragraph.ParagraphFormat.DefaultPortionFormat.LatinFont = <span style="color:blue;">new</span> <span style="color:#2b91af;">FontData</span>(<span style="color:#a31515;">"Segoe UI"</span>));

                    p.ParagraphFormat.DefaultPortionFormat.LatinFont = <span style="color:blue;">new</span> <span style="color:#2b91af;">FontData</span>(<span style="color:#a31515;">"Segoe UI"</span>);

                    i++;
                }

                rowIndex++;
            }

            <span style="color:green;">//Write PPTX to Disk</span>
            pres.Save(<span style="color:#a31515;">@"C:\TempFolder\Aspose\"</span> + guid.ToString() + <span style="color:#a31515;">"_table.pptx"</span>, <span style="color:#2b91af;">SaveFormat</span>.Pptx);
        }</pre><br><br>
Hi Nan,

I have worked with the presentation file using Aspose.Slides for .NET 16.12.0 and have been able to reproduce the issue. A ticket with ID SLIDESNET-38272 has been created in our issue tracking system to investigate and resolve the issue. This thread has been associated with the ticket so that we may share the notification with you once issue will be fixed.

We are sorry for your inconvenience,