Jump to content

Export to Excel


jacmaes
 Share

Recommended Posts

A group of architects doing field and statistical research on city neighborhoods came to me to create an online database that they could edit from anywhere. PW seemed like the perfect choice since it's very easy to customize the admin to fit their needs, and they are indeed quite happy.

Now, however, they'd like to have an Excel file of all the neighborhoods, one on each row, so that they can work with the data offline and produce printed documents of their research.

The PW tree is organized geographically: region > city > neighborhood. In other words, each neighborhood is a page with about 40 fields (and growing). How would you guys go about it? 

Link to comment
Share on other sites

I have recently used this code to create CSV, works great.

// array, with for each row an array
$array = array(
    array('val 1 - row 1', 'val 2 - row 1', 'val 3 - row 1'),
    array('val 1 - row 2', 'val 2 - row 2', 'val 3 - row 2'),
    array('val 1 - row 3', 'val 2 - row 3', 'val 3 - row 3'),
    etc...
    );

	
$out = '';
$handle = fopen('php://temp', 'r+'); // temp read/write file-like wrapper
foreach ($array as $line) fputcsv($handle, $line, ',', '"');
rewind($handle);
while (!feof($handle)) $out .= fread($handle, 8192);
fclose($handle);
echo trim($out);
  • Like 4
Link to comment
Share on other sites

There are other libraries, but this one is pretty powerful:

phpexcel.codeplex.com

Moved to here https://github.com/PHPOffice/PHPExcel

I have used it to generate excel files from PW. Cool thing is that it also allows you to automatically generate charts from the data.

Edited by Pete
Project has moved to Github
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By AndZyk
      Hello,
      we have many projects as pages containing images inside regular image fields and repeater matrix elements. Now we would like to organize our assets.
      ProcessWire saves assets with id as folder name and makes separate folders for repeater matrix elements.
      Is there a way to collect all assets of one page and export them in a folder with the page name/title?
      I think I could achieve this by using the command line wget for this website or maybe by a hook. But maybe someone has done this before. 😉
      Regards, Andreas
    • By Vineet Sawant
      Hi,
      I'm trying to import some heavy data into Processwire, but I'm not sure what would be the best way to do it.
      Usually I use CSV to Pages plugin, but this time the data is too heavy(~40k rows with 10+ columns of excel sheet), thus this plugin can't help.
      I also tried Tasker plugin but I can't seem to go through the setup itself, it requires some template setup but I'm totally clueless about how to do it, so that plugin is not of any use either.
      I wanted to know from you guys how you do it and in future what would be the best way to migrate thousands of rows of data in to PW.
       
      Thanks.
       
       
    • By hellerdruck
      Hi all
      I need to export all the texts from a website to a translation company (as json or csv or txt...). How can this be done? Of course manually, but this website is huge and it would take me years...
      Also, as a second step, importing the translation ...
      Any ideas anyone? Tutorials? Plugins?
      Thanks for your help.
    • By Rodd
      Hi everyone!
      I have a website in a production environment and I want to duplicate it in a local environment. I exported the content of the website (with the 'Site Profile Exporter' module) but I cannot use it actually. I've got an issue with the database. I imported this one in MAMP then.

      I also exported the pages (with the 'ProcessPagesExportImport' module), but I cannot import it to my local website because the fields don't exist. So I created this fields, but I have this error :
      How can I use the elements that already exist and are presents in my database? How can I duplicate correctly the templates, fields and pages?
      Thanks by advance
      PS: Sorry if my english is bad
       
    • By hellerdruck
      Hi all
      I need help with something. Situation: We have let's say 2'000 Files (Excel) that should be displayed (list with links) on a page. We'd need to filter these files by given Keywords or a tree structure or both. Now, I'm looking for a solution whereas our customer can synchronise the files from his local computer with the folder on the webserver. They will update and upload files on a daily basis. Therefore, it would need to synchronise rather than load the files manually in pages or repeaters. Maybe indexing would be an idea, too.
      Are there any modules for Processwire that would help achieving this? Could anyone point me in the right direction?
      Thanks in advance.
×
×
  • Create New...