This project is read-only.

Nested tables and/or multiple images in a single table cell

Feb 21, 2014 at 6:59 PM
I need either nested tables or a way to place multiple images in a single table cell. I have a report to generate, but I can't figure out how to have multiple images in a single table cell. If I can't have multiple images in one cell of a table, then I would need to nest a sub-table with a single image in each of those cells.

This post (https://phpword.codeplex.com/discussions/245828) had code mods on table nesting, but no explanation on how to implement it. I'd pay $ to get this working.
Mar 19, 2014 at 1:51 PM
I REALLY need to be able to add multiple photos in a single table cell. Anyone?
Mar 19, 2014 at 8:31 PM
Ok, I figured out how to add multiple images in a single table cell, however, it inserts a paragraph tag (¶) after each image. Since I want the images side by side, this presents a problem. Surely there's a line in the PHPword code that adds this paragraph tag that I can comment out. Better yet, it would be great if it were something I could switch on/off in the addImage command.
$table = $section->addTable();
$table->addRow();
$cell = $table->addCell(8000);
$cell->addImage('photos/image1.JPG');
$cell->addImage('photos/image2.JPG');
$cell->addImage('photos/image3.JPG');
Mar 20, 2014 at 4:11 AM
Unfortunately, there's no way to do that on PHPWord 0.6.2 (CodePlex). But you can do that using Text Run on PHPWord 0.8 (GitHub).
$table = $section->addTable();
$table->addRow();
$cell = $table->addCell(8000);
$textrun = $cell->createTextRun();
$textrun->addImage('photos/image1.JPG');
$textrun->addImage('photos/image2.JPG');
$textrun->addImage('photos/image3.JPG');
The development of PHPWord continues on GitHub. You can try the 0.8 version. It should be compatible with 0.6.2 plus tons of additional features.
Mar 20, 2014 at 3:12 PM
That's really cool that you're continuing to develop this. Thanks!!

However, I've been running version 0.6.3 of PHPWord for a while now and have it doing mostly what I want it to do, but I see there are new features in version 0.8 that would completely do what I need. I downloaded the zip file from GitHub and replaced my /classes folder with the new /classes folder and even with the most basic of test files, I immediately get this error: Fatal error: Class 'PHPWord_DocumentProperties' not found in E:\Inetpub\wwwroot\mysite\Classes\PHPWord.php on line 99.
Mar 20, 2014 at 5:14 PM
I think it's the PHP version. You should use 5.3. Sorry about that, but the team decided to move forward and use all the good stuffs on 5.3.