Skip to content

Set Table Direction RTL #1549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mmasomi73 opened this issue Jan 2, 2019 · 8 comments
Closed

Set Table Direction RTL #1549

mmasomi73 opened this issue Jan 2, 2019 · 8 comments

Comments

@mmasomi73
Copy link

mmasomi73 commented Jan 2, 2019

How to set table direction rtl?
it's my code:

        $style = array('rtl' => true,
                       'name' => 'B Mitra',
                       'size' => 12);

        $borderStyle = array('borderSize' => 6,
                            'borderColor' => '000000');

        $table = $section->addTable($borderStyle);
        $cellHCentered = array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER);
        $cellHEnd = array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END);
        $cellVCentered = array('valign' => 'center');
        $i = 0;

        //--------------= Questions Header
        $table->addRow();
        $cell = $table->addCell(500,$cellVCentered);
        $textrun = $cell->addTextRun($cellHCentered);
        $textrun->addText('ردیف', $style);

        $cell = $table->addCell(11000);
        $textrun = $cell->addTextRun($cellHEnd);
        $textrun->addText('سوالات', $style);

        $cell = $table->addCell(500,$cellVCentered);
        $textrun = $cell->addTextRun($cellHCentered);
        $textrun->addText('بارم', $style);
@troosan
Copy link
Contributor

troosan commented Jan 2, 2019

Isn't this what you are trying to produce?

image

@mmasomi73
Copy link
Author

No, it's exactly reversed, in rtl table columns arranged right to left; first column in right side and last column in left. One solution is arrange columns reverse, but not correct solution;
2019-01-03_09-59-00

@troosan
Copy link
Contributor

troosan commented Jan 3, 2019

Oh I see, it's not only the text that should be RTL, it's also the column order.
Can you provide a simple document with just that so I can see the generated XML?

@troosan
Copy link
Contributor

troosan commented Jan 3, 2019

I have word 2017 for mac, and I don't seem to have this "table direction" option :-(
But I tried with LibreOffice, where the option is present.
It seems what we need is http://www.datypic.com/sc/ooxml/e-w_bidiVisual-1.html
I'll try to create a pull request for this.

@mmasomi73
Copy link
Author

yes, Sure.
Questions (13).docx
this file created with office 2013, and table is rtl.

@mmasomi73
Copy link
Author

I have word 2017 for mac, and I don't seem to have this "table direction" option :-(
But I tried with LibreOffice, where the option is present.
It seems what we need is http://www.datypic.com/sc/ooxml/e-w_bidiVisual-1.html
I'll try to create a pull request for this.

Exactly, for rtl table use <w:bidiVisual/>

@troosan
Copy link
Contributor

troosan commented Jan 3, 2019

@mmasomi73 code has been merged to develop branch.
You can use it by defining the dependency version as "dev-develop"

@farzadjamshidi
Copy link

farzadjamshidi commented Sep 21, 2019

Hi @troosan and @mmasomi73
how about RTL in table of content?

Untitled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants