Skip to content
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

Add text to table cell in one row #1949

Open
AryaDarisova opened this issue Oct 20, 2020 · 2 comments
Open

Add text to table cell in one row #1949

AryaDarisova opened this issue Oct 20, 2020 · 2 comments

Comments

@AryaDarisova
Copy link

Hello! Is it really to add text in the same line with different font color into the table cell? Now I'm using addText(), but that add text on the next line. I want it to look like on the second photo
image
image

@FajeSu
Copy link

FajeSu commented Sep 26, 2021

Hello.
If the question is still relevant, You should use addTextRun()
https://phpword.readthedocs.io/en/latest/elements.html#texts

/**
 * @var \PhpOffice\PhpWord\Element\Cell $cell
 */
$textRun = $cell->addTextRun();
$textRun->addText('Hello World (black)! ');
$textRun->addText('Hello World (red)! ', ['color' => 'ff0000']);
$textRun->addText('Hello World (blue)! ', ['color' => '0000ff']);

@kamleshwebtech
Copy link

Hello. If the question is still relevant, You should use addTextRun() https://phpword.readthedocs.io/en/latest/elements.html#texts

/**
 * @var \PhpOffice\PhpWord\Element\Cell $cell
 */
$textRun = $cell->addTextRun();
$textRun->addText('Hello World (black)! ');
$textRun->addText('Hello World (red)! ', ['color' => 'ff0000']);
$textRun->addText('Hello World (blue)! ', ['color' => '0000ff']);

Your suggestion giving output in 3 separate lines while we need solution/all the texts in a single line. Any suggestion, please share. Thanks.

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