Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier dutoit committed Oct 8, 2010
0 parents commit 7073787
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
A software company that produces the dominant speadsheet software has been highly creative as what the "C" in "CSV" stands for. In a french version of Excel, it expects as ";" as separator, but a "," in a US version.

Moreover, the charset is always implicit and never UTF-8. To add insult to injury, there isn't any way for the end user to choose what it the charset.

Bottom line, there isn't any way to be able to generate a csv that would be always properly read by the dominant speadsheet. That's almost as if done on purpose to make harder to communicate with the "outside" world. Who would be deviant enough to do that on purpose ?

Long story short, the dominant spreadsheet is able to convert from an html table into its internal format with minimum complaints, hence bypassing all these csv joy.

Kurund has implemented a hook during the code sprint in Bristol, making the magic possible and the dream true.

X+
7 changes: 7 additions & 0 deletions civi_export.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = CiviCRM Export
description = Export into an excel format directly instead of csv
version = 3.2
package = CiviCRM
dependencies[] = civicrm
core = 6.x
php = 5.2
40 changes: 40 additions & 0 deletions civi_export.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

function civi_export_civicrm_export( $exportTempTable, $headerRows, $sqlColumns, $exportMode ) {
$writeHeader = true;
$offset = 0;
$limit = 200;

$query = "
SELECT *
FROM $exportTempTable
";
require_once 'CRM/Core/Report/Excel.php';
while ( 1 ) {
$limitQuery = $query . "
LIMIT $offset, $limit
";
$dao = CRM_Core_DAO::executeQuery( $limitQuery );

if ( $dao->N <= 0 ) {
break;
}

$componentDetails = array( );
while ( $dao->fetch( ) ) {
$row = array( );

foreach ( $sqlColumns as $column => $dontCare ) {
$row[$column] = $dao->$column;
}

$componentDetails[] = $row;
}
CRM_Core_Report_Excel::writeHTMLFile( "Export_Records", $headerRows,
$componentDetails, null, $writeHeader );
$writeHeader = false;
$offset += $limit;
}

CRM_Utils_System::civiExit( );
}

0 comments on commit 7073787

Please sign in to comment.