diff --git a/php-export-data.class.php b/php-export-data.class.php index d983cf7..b3c3254 100755 --- a/php-export-data.class.php +++ b/php-export-data.class.php @@ -10,15 +10,17 @@ abstract class ExportData { protected $stringData; // stringData so far, used if export string mode protected $tempFile; // handle to temp file (for export file mode) protected $tempFilename; // temp file name and path (for export file mode) + protected $thousandsSeparator; // handle thousands separator in excel export public $filename; // file mode: the output file name; browser mode: file name for download; string mode: not used - public function __construct($exportTo = "browser", $filename = "exportdata") { + public function __construct($exportTo = "browser", $filename = "exportdata", $thousandsSeparator = false) { if(!in_array($exportTo, array('browser','file','string') )) { throw new Exception("$exportTo is not a valid ExportData export type"); } $this->exportTo = $exportTo; $this->filename = $filename; + $this->thousandsSeparator = $thousandsSeparator; } public function initialize() { @@ -168,6 +170,7 @@ function generateHeader() { // Set up styles $output .= "\n"; $output .= "\n"; + $output .= "\n"; $output .= "\n"; // worksheet header @@ -206,6 +209,7 @@ private function generateCell($item) { // as text if number is longer than that. if(preg_match("/^-?\d+(?:[.,]\d+)?$/",$item) && (strlen($item) < 15)) { $type = 'Number'; + $style = $this->thousandsSeparator ? 's63' : null; // defined in header; tells excel to format number with thousands separator } // Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can // also have an optional time after the date.