how do I create cells with rowspan more than 1?
that is cellspan, what I need is rowspan, it should be done this way:
$cell->getStyle()->setVMerge(2);
but that is not working properly
In memory, it's @kaystrobach who have implemented rowspan and colspan to cell in PR #21. May be, could he help us on this point ?
@carlosrochap can you please post you document creation code snippet?
the work for rowspan and colspan is based on http://tegarrputra.wordpress.com/2011/11/02/merging-cells-in-msword-2007-table-using-phpword/ as stated in my original issue #21
In my case both worked fine.
sure, here is my code, I have tried different approaches but no luck so far, thanks for your help.
require_once '../Classes/PHPWord.php';
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$table = $section->addTable();
$table->addRow();
$sc = $table->addCell(10);
$sc->addText('Cell 11');
$table->addCell(10)->addText('Cell 12');
$table->addRow();
$table->addCell(10)->addText('Cell 21');
$table->addCell(10)->addText('Cell 22');
$style = $sc->getStyle();
$style->setVMerge(2);
// Save File
echo date('H:i:s') , " Write to Word2007 format" , EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save(str_replace('.php', '.docx', FILE));
if i read your code right you make 2x2 cells and try to make rowspan the firstone
please try to make the following
| a | b |
+----------+
| c |
+----------+
then you should be able to rowspan cell a
mm, here is what I need:
| || b || |
+ A ++----------++ E +
| || c | d || |
+----------++----------++----------+
in your example C has just a colspan of 2, I need rowspan too to do something like the previous example
See Sample_09_Tables.php on my latest commit.
$section->addTextBreak(1);
$section->addText("Table with colspan and rowspan", $header);
$styleTable = array('borderSize' => 6, 'borderColor' => '999999');
$cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center');
$cellRowContinue = array('vMerge' => 'continue');
$cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
$cellHCentered = array('align' => 'center');
$cellVCentered = array('valign' => 'center');
$PHPWord->addTableStyle('Colspan Rowspan', $styleTable);
$table = $section->addTable('Colspan Rowspan');
$table->addRow();
$table->addCell(2000, $cellRowSpan)->addText('A', null, $cellHCentered);
$table->addCell(4000, $cellColSpan)->addText('B', null, $cellHCentered);
$table->addCell(2000, $cellRowSpan)->addText('E', null, $cellHCentered);
$table->addRow();
$table->addCell(null, $cellRowContinue);
$table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
$table->addCell(null, $cellRowContinue);
is it working as expected?
perfect
Thank you ;), I will try that on my project
@carlosrochap When you will test, could you send us a feedback in order that I close this issue ?
Sure, I will do it this week, not sure which day, but I will let you know right away..
@carlosrochap Some news ?
sorry for the delay, it's working like a charm :), thanks @ivanlanin / everyone
I close it :)
Yay! One more issue closed :) Thanks @carlosrochap
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:InetpubwwwrootmysiteClassesPHPWord.php on line 99.
You need to open a new issue with this.
Thanks, I'm a github newb.
i have tried what was done by @ivanlanin but it didn't work. even just a colspan it didn't work too. i use codeigniter. the message below it. somebody help me please :(

please open the docx as zip file and search for the content you are expecting in the cell.
Then paste the surounding xml ...
Additionally show the details from the alert Word displays ...
As developer you should now, that as much information as possible helps solving problems :smile:
@kaystobach thx alot.. i have found a way. the problems is defference version of phpword that i used. the above code has worked now. :D
Glad to know it's working :)
How can I create Table like this one?

ivanlanin - your code in my PHPWord 0.6.3 version gives me something like that. Why?
What is wrong? I took code directly from your example.
And one more question - I have no possibility to use Composer. Where can I found pack PHPWord code which I can use without Composer (autoload.php and Vendor)?
@markoniusz
You could build your own autoloader or use composer to build a "vendor" directory that you then commit on your project. I fail to see an instance where you can add code to a project but not use composer to create that code.
Package it yourself as stated
Typically i use a build system build a bundle of all my dependencies (you can do it locally on your maschine) and upload the result
Von meinem iPhone gesendet
Am 29.04.2016 um 17:54 schrieb markoniusz [email protected]:
And one more question - I have no possibility to use Composer. Where can I found pack PHPWord code which I can use without Composer (autoload.php and Vendor)?
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
Can't I use rowspan on <td> while using Html? It's not working, only colspan...
@SuperHaoHaoHao english please - otherwise it’s hard to follow the discussion
Most helpful comment
Yup. Here's the screenshot of the result:
The value of vMerge is not an integer. It's a string of either
restartorcontinue. We put the blank cell withvMerge = continue.