jacmaes Posted April 8, 2014 Share Posted April 8, 2014 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 More sharing options...
DaveP Posted April 8, 2014 Share Posted April 8, 2014 Just off the top of my head, CSV files are easily read by Excel, so you could create a php file that bootstraps PW to generate a CSV file, outputting the appropriate mime-type etc. 3 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted April 8, 2014 Share Posted April 8, 2014 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); 4 Link to comment Share on other sites More sharing options...
jacmaes Posted April 8, 2014 Author Share Posted April 8, 2014 Great! Thanks guys, I'll give it a try. Link to comment Share on other sites More sharing options...
Beluga Posted April 8, 2014 Share Posted April 8, 2014 There's a plugin for DataTables that exports XLS: http://www.datatables.net/extras/tabletools/ Soma has created a module that let's you easily apply DataTables to your PW modules: https://processwire.com/talk/topic/5364-jquery-datatables-modulejs/ 1 Link to comment Share on other sites More sharing options...
adrian Posted April 8, 2014 Share Posted April 8, 2014 (edited) 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 September 15, 2015 by Pete Project has moved to Github 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now