PHPExcel and Ajax best practices

Topics: Developer Forum
May 19, 2008 at 7:01 PM
Lets say my application is using an excel formula sheet as a calculation engine with a web front-end, what would be the best method to persist the PHPExcel object to achieve two-way communication using AJAX methodology?

Some choices are:
  1. store the PHPExcel object in a session variable
  2. serialize and de-serialize the object on every call
  3. write and load the excel sheet on every call
  4. store the PHPExcel object in a database, retrieve and insert on every call

What have some of you been using to achieve this?  Currently I store the object in a session variable, but wonder about the amount of resources it takes to do this.  Has anyone tried the database method?  What is the most efficient solution?

Coordinator
May 20, 2008 at 7:23 AM
Well, those are some options... There will however always be serialization involved.

Another option you can add to your list:
  5. Use PHPExcel_Writer_Serialized and PHPExcel_Reader_Serialized to serialize the file to disk instead of in the session variable

To be honest, PHPExcel + Ajax was one of my very first ideas when starting to build PHPExcel. Never got the time to implement an example. Quite curious about your application :-)
Coordinator
May 20, 2008 at 8:55 AM

If you have the APC module enabled for PHP, use that rather than disk or session to store the object.

Initiate the object via a command-line daemon process, and let the Ajax call simply communicate with an IPC wrapper that calls the daemon to execute requests. That way the PHPExcel object is always available once it's been instantiated, until you send an Ajax call to terminate the daemon process.

May 20, 2008 at 9:16 AM
The application is an implementation of a supply chain simulation, similar to the mit beer game.  It uses PHPExcel as a calculation engine while  updating a matrix of cells on the
client side.
May 20, 2008 at 9:31 AM


maartenba wrote:
Well, those are some options... There will however always be serialization involved.

Another option you can add to your list:
  5. Use PHPExcel_Writer_Serialized and PHPExcel_Reader_Serialized to serialize the file to disk instead of in the session variable

To be honest, PHPExcel + Ajax was one of my very first ideas when starting to build PHPExcel. Never got the time to implement an example. Quite curious about your application :-)

The application is an implementation of a supply chain simulation, similar to the mit beer game.  It uses PHPExcel as a calculation engine while  updating a matrix of cells on the
client side.
May 20, 2008 at 9:32 AM


MarkBaker wrote:

If you have the APC module enabled for PHP, use that rather than disk or session to store the object.

Initiate the object via a command-line daemon process, and let the Ajax call simply communicate with an IPC wrapper that calls the daemon to execute requests. That way the PHPExcel object is always available once it's been instantiated, until you send an Ajax call to terminate the daemon process.



How would one go about that on a windows box?