-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Whenever I use italic/bold/underline in a table, it will break into another line when generated into word document. #1252
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
Comments
I noticed if there has any tag in between td tag, then it will cause the tag in between td to break into another line. For example: |
So it's there any way to solve this problem ? |
might be fixed by #380 |
Hi troosan, I just tried but it still the same. |
I noticed it didn't go to two of that files which u show me the file in the link. |
I noticed it goes to phpoffice/phpword/src/PhpWord/Element instead of going to phpoffice/phpword/src/PhpWord/Writer |
Just now I accidentally tried putting a paragraph tag in the html It won't break into next line even if I put bold/italic/underline and this is what I wanted. |
Hi Troosan, is there any way to make the tag (span/bold/italic/underline) to prevent it from breaking into another line in td tag? |
Pls help me because I need to fix this bug by this end of tmr. Thank you |
Now I finally noticed the main problem is caused by Text. |
@lvc2202 The following fixes your particular case In private static function parseCell($node, $element, &$styles)
{
$cellStyles = self::recursiveParseStylesInHierarchy($node, $styles['cell']);
$colspan = $node->getAttribute('colspan');
if (!empty($colspan)) {
$cellStyles['gridSpan'] = $colspan - 0;
}
$cell = $element->addCell(null, $cellStyles);
return $cell->addTextRun();
} Basically, instead of returning a cell, directly add a TextRun in it and return that instead. As I'm not sure this will not bring other issues, I'll not commit it yet, it needs more testing. |
Oh I see. I just tried and it show this error "Cannot add Table in TextRun. ". |
I found another way is by doing this but not sure will it have any issues in the future.
` |
Can you provide a sample? Do you have tables inside tables? <table align="center" style="width: 50%; border: 6px #0000FF double;">
<thead>
<tr style="background-color: #FF0000; text-align: center; color: #FFFFFF; font-weight: bold; ">
<th style="width: 50pt">header a</th>
<th style="width: 50">header b</th>
<th style="background-color: #FFFF00; border-width: 12px"><span style="background-color: #00FF00;">header c</span></th>
</tr>
</thead>
<tbody>
<tr><td style="border-style: dotted;">1</td><td colspan="2">This cell spans the 2 bellow</td></tr>
<tr><td>This is <b>bold</b> text</td><td></td><td><img src="resources/_earth.jpg" width="50"/></td></tr>
</tbody>
</table> |
Sure why not. This sample has some other language but don't care about it. |
This is another sample I made which has tables in tables.
|
Hi Troosan, the above commits works nicely but on certain condition like this below will cause this error ("Cannot add ListItemRun in TextRun")
|
@lvc2202 try now, should be ok |
Hi troosan, where do I get the changes ? |
You could find them in #1273 |
Awesome, it's working properly now. |
For example:
I used bold in table and it can become bold but it break into another line as well when generated into word document.
<table border="0" cellpadding="0" cellspacing="0" style="width:500px"><tbody><tr><td>co<strong>lumn</strong> 1</td><td>column 2</td></tr></tbody></table>
I want to use bold in table without breaking into another line.
Any idea how to fix it ? Please help me thank you.
The text was updated successfully, but these errors were encountered: