When I create or add html table in my .docx file, document is not displayed on the Google Doc Viewer.
When I create or add html table in my .docx file, document is not displayed on the Google Doc Viewer.
Hello,
Please try the most simple example of a table to check if it works. Using embedHTML, the HTML is transformed to WordML so it must works fine with any DOCX viewer; maybe you're adding some element that Google Doc doesn't support.
Regards.
$html = '<table style="border-collapse: collapse; width: 200px;" border="1">
<tbody>
<tr>
<td>123</td>
<td>321</td>
</tr>
</tbody>
</table>';
$docx = new CreateDocx();
$docx->embedHTML($html);
$docx->createDocx('test');
Don't show in GDocs Viewer.
It is noteworthy that, if I re-save file as 'test.docx' in MS Word, I can view this file in GDocs Viewer
Proof:
Before re-save:
https://docs.google.com/viewer?url=http://fs1.d-h.st/download/00075/FdD/test.docx
After re-save:
https://docs.google.com/viewer?url=http://fs1.d-h.st/download/00075/UC5/test.docx
Hello,
We've been checking the issue and it's a Google Doc problem. The problem is due to this element:
<w:gridCol/>
Google doesn't allow to set an empty w:gridCol property, but as you can read in the standard:
http://www.schemacentral.com/sc/ooxml/e-w_gridCol-1.html
w:gridCol is not mandatory but optional. So as PHPDocX follows the standard as much as possible, we'll don't force a value for this element. We recommend you to contact Google to fix it.
Regards.
Forgive me for arrogance, but you could not send a working code to the generated files in PHPDOCX open correctly in Google Viewer?
I have absolutely no time to contact Google, but the service I needed now.
Thank you for understanding
Hello,
We can't calculate automatically the value of the properties of <w:gridCol/> tag, it takes a value when it's displayed in a document or saved by them. The problem is that Google fails on that tag of the OOXML standard:
http://www.schemacentral.com/sc/ooxml/e-w_gridCol-1.html
OpenOffice fails too when reading some tags of the standard.
PHPDocX is a library to generate DOCX documents according to a standard and we must apply this OOXML standard and not solve every miss and errors of the viewers.
Of course as PHPDocX is an open library, you can change the code to fit your needs.
Thank you for your understanding.
Regards.
Hello,
The next version of PHPDocX, 3.5.1, allows you to fix this issue forcing a width:
$html = '<table style="border-collapse: collapse; width: 200px;" border="1">
<tbody>
<tr>
<td width="200px;">123</td>
<td width="200px;">321</td>
</tr>
</tbody>
</table>';
$docx = new CreateDocx();
$docx->enableCompatibilityMode();
$docx->embedHTML($html);
$docx->createDocx('test');
Regards.
[quote=jorgelj]
Hello,
The next version of PHPDocX, 3.5.1, allows you to fix this issue forcing a width:
$html = '<table style="border-collapse: collapse; width: 200px;" border="1">
<tbody>
<tr>
<td width="200px;">123</td>
<td width="200px;">321</td>
</tr>
</tbody>
</table>';
$docx = new CreateDocx();
$docx->enableCompatibilityMode();
$docx->embedHTML($html);
$docx->createDocx('test');
Regards.
[/quote]
Don't work ((