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

row span? #74

Closed
carlosrochap opened this issue Feb 27, 2014 · 36 comments
Closed

row span? #74

carlosrochap opened this issue Feb 27, 2014 · 36 comments

Comments

@carlosrochap
Copy link

how do I create cells with rowspan more than 1?

@gabrielbull
Copy link
Member

@Progi1984 Progi1984 added this to the 0.7.1 milestone Feb 27, 2014
@carlosrochap
Copy link
Author

that is cellspan, what I need is rowspan, it should be done this way:

$cell->getStyle()->setVMerge(2);

but that is not working properly

@Progi1984
Copy link
Member

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 ?

@kaystrobach
Copy link

@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.

@carlosrochap
Copy link
Author

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));

@kaystrobach
Copy link

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

@carlosrochap
Copy link
Author

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

@ivanlanin
Copy link
Contributor

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);

@kaystrobach
Copy link

is it working as expected?

@ivanlanin
Copy link
Contributor

Yup. Here's the screenshot of the result:

2014-03-10-211025-ss

The value of vMerge is not an integer. It's a string of either restart or continue. We put the blank cell with vMerge = continue.

@kaystrobach
Copy link

perfect

@carlosrochap
Copy link
Author

Thank you ;), I will try that on my project

@Progi1984
Copy link
Member

@carlosrochap When you will test, could you send us a feedback in order that I close this issue ?

@carlosrochap
Copy link
Author

Sure, I will do it this week, not sure which day, but I will let you know right away..

@Progi1984 Progi1984 mentioned this issue Mar 12, 2014
5 tasks
@Progi1984
Copy link
Member

@carlosrochap Some news ?

@carlosrochap
Copy link
Author

sorry for the delay, it's working like a charm :), thanks @ivanlanin / everyone

@Progi1984
Copy link
Member

I close it :)

@ivanlanin
Copy link
Contributor

Yay! One more issue closed :) Thanks @carlosrochap

@BillVA
Copy link

BillVA commented Mar 20, 2014

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.

@gabrielbull
Copy link
Member

You need to open a new issue with this.

@BillVA
Copy link

BillVA commented Mar 20, 2014

Thanks, I'm a github newb.

@ahrinal
Copy link

ahrinal commented May 14, 2014

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 :(
failed

@kaystrobach
Copy link

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 😄

@ahrinal
Copy link

ahrinal commented May 14, 2014

@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

@ivanlanin
Copy link
Contributor

Glad to know it's working :)

@sajuuk78
Copy link

sajuuk78 commented Dec 7, 2015

How can I create Table like this one?
table

@markoniusz
Copy link

ivanlanin - your code in my PHPWord 0.6.3 version gives me something like that. Why?
images here
What is wrong? I took code directly from your example.

@markoniusz
Copy link

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)?

@gabrielbull
Copy link
Member

@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.

@kaystrobach
Copy link

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 notifications@github.com:

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

@danilocarva9
Copy link

Can't I use rowspan on <td> while using Html? It's not working, only colspan...

@SuperHaoHaoHao
Copy link

是啊。下面是结果的截图:

2014-03-10-211025-ss

价值vMerge不是整数。它是一根绳子任一种restartcontinue..我们把空白细胞vMerge = continue.

Invalid style value: fusion Options:restart,continue

@kaystrobach
Copy link

@SuperHaoHaoHao english please - otherwise it’s hard to follow the discussion

@madeingnecca
Copy link

I am also interested in knowing how to build a table like the one posted by @sajuuk78

@samsul97
Copy link

image
Hello Im sorry, may I ask? How can I create Table like this one? Thank you.

@markonikolicdir
Copy link

Yup. Here's the screenshot of the result:

2014-03-10-211025-ss

The value of vMerge is not an integer. It's a string of either restart or continue. We put the blank cell with vMerge = continue.

I

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);

When I try to create pdf from this example, in column "E" missing "rowspan", do you know what can be a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests