CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • CiviReports to XLS rather than CSV
Pages: [1]

Author Topic: CiviReports to XLS rather than CSV  (Read 1985 times)

Tchiot Galopin

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 7.12
  • MySQL version: 5.1.44
  • PHP version: 5.3.3.7
CiviReports to XLS rather than CSV
September 22, 2011, 03:38:55 pm
Hello to you all,

A very simple question... at first: has anyone ever tried to offer xls exportation files rather than csv?

Exportations are very useful and sending automatics CiviReports (eg list of members) using such cronjob is a must :

Quote
.../liste/sites/all/modules/civicrm/bin/CiviReportMail.php?instanceId=10&reset=1&sendmail=1&output=csv&name=***&pass=***&key=***

However, many of my members, using CiviCRM or recipients of these reports, have not LibreOffice and they have troubles to import CSV files into MS Excel.

I do not want to know if Excel is good or bad, that's not the question. I just want that my militants have easy access to data, even if they only have very limited computer skills.

So, do you think it is possible:
  • to offer XLS reports exportation
  • to permit the automatic sending of such XLS reports by Cron

Thank you in advance for your answers  ;)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviReports to XLS rather than CSV
September 23, 2011, 09:38:00 am

for 1. check:

http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmexport

I suspect you might need to do some code changes to allow 2 to happen

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Tchiot Galopin

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 7.12
  • MySQL version: 5.1.44
  • PHP version: 5.3.3.7
Re: CiviReports to XLS rather than CSV
September 26, 2011, 11:08:42 am
In fact, the easiest solution was to configure the production of CSV in order to allow the correct interpretation by Excel during the opening.
I do not know in other languages​​, but in French, Excel opens the CSV directly when they have " ; " (rather than " , "), encoded in Windows-1252.

So I modified the file /modules/civicrm/CRM/Report/Utils/Report.php :

Quote
// Add the headers.
        $csv .= implode(';', $headers) . "\n";
        $displayRows = array();
        $value       = null;
        foreach ( $rows as $row ) {
            foreach ( $columnHeaders as $k => $v ){
                if ( $value = CRM_Utils_Array::value( $v, $row ) ) {
                    // Remove HTML, unencode entities, and escape quotation marks.
                    $value =
                  mb_convert_encoding ($value , "Windows-1252", "UTF-8");
               $value =
                        str_replace('"', '""', html_entity_decode(strip_tags($value)));                   
                    if ( CRM_Utils_Array::value( 'type', $form->_columnHeaders[$v] ) & 4 ) {
                        if ( CRM_Utils_Array::value( 'group_by', $form->_columnHeaders[$v] ) == 'MONTH' ||
                             CRM_Utils_Array::value( 'group_by', $form->_columnHeaders[$v] ) ==  'QUARTER' ) {
                            $value =  CRM_Utils_Date::customFormat( $value, $config->dateformatPartial );
                        } elseif ( CRM_Utils_Array::value( 'group_by', $form->_columnHeaders[$v] ) == 'YEAR' ) {
                            $value =  CRM_Utils_Date::customFormat( $value, $config->dateformatYear );
                        } else {
                            $value =  CRM_Utils_Date::customFormat( $value,'%d/%m/%Y' );
                        }
                    } else if ( CRM_Utils_Array::value( 'type', $form->_columnHeaders[$v] ) == 1024 ) {
                        $value =  CRM_Utils_Money::format( $value );
                    }
                    $displayRows[$v] = '"'. $value .'"';
                } else {
                    $displayRows[$v] = " ";
                } 
            }
            // Add the data row.
            $csv .= implode(';', $displayRows) . "\n";
        }

        return $csv;
    }

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: CiviReports to XLS rather than CSV
September 26, 2011, 03:07:00 pm
Hi,

This module https://github.com/tttp/civi_export allows to export to html and xls (kind of, that's a bit of flash and javascript that converts the html).

It should work out of the box for searches/advanced searches, for report not sure, probably not but might be a base.

And as for the CSV with ; you will be screwed at one point or another if you have a contact that has a char outside on windows-1252 (eg. eastern europe...)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Re: CiviReports to XLS rather than CSV
February 27, 2014, 04:20:46 am
Hi guys,

getting back to this old issue, we have the need to get the CSV Report's files in ISO-8859-7 encoding (greek).
Does it make sense to add an new settings in Localization Admin Section (similar to Legacy Encoding field) to set the enconding for all exported CSV files ? (UTF-8 can be set by default)

We can contribute with a Pull Request on this

cheers!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • CiviReports to XLS rather than CSV

This forum was archived on 2017-11-26.