TableCsvImportExport by Adrian Jones

Admin and front-end importing and exporting of CSV formatted content for Profields Table fields.

Table CSV Import / Export

Processwire module for admin and front-end importing and exporting of CSV formatted content for Profields Table fields.

https://processwire.com/talk/topic/7905-profields-table-csv-importer-exporter/

Access to the admin import/export for non-superusers is controlled by two automatically created permissions: table-csv-import and table-csv-export

Another permission (table-csv-import-overwrite) allows you to control access to the overwrite option when importing.

The overwrite option is also controlled at the field level. Go to the table field's Input tab and check the new "Allow overwrite option" if you want this enabled at all for the specific field.

Front-end export of a table field to CSV can be achieved with the exportTableCsv() method:

<?php
// export as CSV if csv_export=1 is in url
if($input->get->csv_export==1){
	$modules->get('ProcessTableCsvExport'); // load module
	$options = array(
        'delimiter' => ',',
        'enclosure' => '"',
        'extension' => 'csv',
        'multipleValuesSeparator' => '|',
        'namesFirstRow' => true,
        'columns' => array('field1','field2'), // columns to export can be index starting at 1, or column names
        'selector' => 'field1%=foo, field2%=bar'
    );
	$p->exportTableCsv('field_name', $options);
}
// display content of template with link to same page with appended csv_export=1
else{
   include("./head.inc");

   echo $page->field_name->render(); //render table - not necessary for export
   echo "<a href='./?csv_export=1'>Export Table as CSV</a>"; //link to initiate export

   include("./foot.inc");
}

Front-end import can be achieved with the importTableCsv() method:

$modules->get('TableCsvImportExport'); // load module
$options = array(
    'delimiter' => ',',
    'enclosure' => '"',
    'convertDecimals' => false,
    'multipleValuesSeparator' => '|',
    'namesFirstRow' => false
);
$page->importTableCsv('field_name', $csvData, $options);
Support forum:

https://processwire.com/talk/topic/7905-profields-table-csv-importer-exporter/

License


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

(See included LICENSE file for full license text.)

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • This week ProcessWire 3.0.214 is on the dev branch. Relative to 3.0.213 this version has 16 new commits which include the addition of 3 new pull requests, 6 issue fixes, a new WireNumberTools utility class, and various other improvements. More
    17 March 2023
  • ProcessWire 3.0.213 core updates: This week we’ll look at the new WireSitemapXML module, a new WireNumberTools core class, and a new ability for Fieldtype modules to specify useful ready-to-use configurations when creating new fields. More
    24 February 2023
  • ProcessWire 3.0.212 core updates— More
    17 February 2023

Latest news

  • ProcessWire Weekly #463
    In the 463rd issue of ProcessWire Weekly brings we'll check out the latest weekly update from Ryan, some weekly forum and online highlights, and more. Read on!
    Weekly.pw / 26 March 2023
  • ProcessWire 3.0.213 core updates
    This week we’ll look at the new WireSitemapXML module, a new WireNumberTools core class, and a new ability for Fieldtype modules to specify useful ready-to-use configurations when creating new fields.
    Blog / 24 February 2023
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani