Forum


Replies: 13   Views: 4705
Very slow / maximum execution time addtemplatevariable with table of >50 rows
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by m.elfring  · 18-11-2011 - 10:41

Hello,

When i use phpdocx to create documents from a template that contains a table, the generation is very (too) slow.
I've tried using a very clean template (just containing a table) but nothing seems to help.
When the query (i run against a database to get the content of the table) returns more than say 50 rows most of the time the script stops: Maximum execution time of 60 seconds exceeded in /var/www/html/changes/phpdocx/classes/CreateTemplate.inc on line 1248

My code:

$docx = new CreateDocx();
$docx->addTemplate("reports/templates/".$row["template_doc"]);

....
Get data from an table in an oracle database:
oci_fetch_all($q, $rows, null, null, OCI_FETCHSTATEMENT_BY_ROW);
...

Add the data to the document:
$docx->addTemplateVariable( $rows, 'table', array ( 'header'=> true) )


I've tried several table's, using more or less columns, nothing seems to help.

Could you advise?

Thanks,
Marcel Elfring







Posted by m.elfring  · 11-04-2013 - 12:13

By the way, using phpdocx 2.4 pro

regards,
Marcel Elfring

Posted by admin  · 11-04-2013 - 12:13

Hello,

Phpdocx uses Xpath and DOM to add new content on templates (lists and tables), so each new replacement needs more resources. We're working on improvements related to this feature.

A quick solution is to add a single placeholder (like $VAR_TABLE$), use phpdocx to create a table (addTable) and replace the placeholder within the WordML generated by phpdocx.

Regards.

Posted by m.elfring  · 11-04-2013 - 12:13

Thanks for the reply.

It raises two questions:

1. When will the updated version be available? In this current situation it is not usable for my company.

2. Your quick workarround:

Dou you mean I need to create a new docx instance that renders a table using AddTable and add it to the the first docx instance using AddTemplateVariable?

Could you provide some sample code?

tx,
Marcel Elfring

Posted by kpholland  · 02-12-2013 - 16:31

We are having the same problem with phpdocx.... It's to slow... We are getting a Word document backup in more the 40 seconds...


Posted by kpholland  · 03-12-2013 - 10:22

We are using version PHPDocX 3.6

Posted by jorgelj  · 03-12-2013 - 11:09

Hello,



We wrote a post about PHPDocX performace:



http://www.phpdocx.com/blog-news/phpdocx-35-general-performance-benchmark



And you can see it's really fast. Maybe you need to optimize your server config.



Regards.


Posted by kpholland  · 03-12-2013 - 15:44

What do you mean with server config in the reply? We have only one template file that generate one Word page only and that takes 63 seconds....

Posted by jorgelj  · 03-12-2013 - 19:30

Hello,



We have done a lot of tests and the results are in this post:



http://www.phpdocx.com/blog-news/phpdocx-35-general-performance-benchmark



I mean that maybe there're something on your server that could be optimized. Because the tests we have done on three servers (Debian, Ubuntu and Windows) show that PHPDocX is very fast.



Of course you could send us the script you're using (and the template) to run it and see how long it takes.



Regards


Posted by kpholland  · 04-12-2013 - 07:58

Dear Jorgelj, Can you send me your emailadres?

Posted by jorgelj  · 04-12-2013 - 08:55

Hello,



Please contact us using this form http://www.phpdocx.com/contact . And we'll reply to you.



Regards.


Posted by kevin_cietech  · 15-01-2014 - 15:05

Hi,



I have the same problem. I need to generate a word document from a template of 17 pages.



Mainly generated by variables, the generation takes more than 40 seconds.



The demo version is slower than the pro one ?



I trying the demo for some tests before bying a licence.



Regards.


Posted by jorgelj  · 15-01-2014 - 16:30

Hello,



The PRO version is faster than the demo version.



Regards.