KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

CSV Export adding thousand separator to number columns #3424

Open Michael Boccardi opened this topic on on Mar 15 - 2 comments

Michael Boccardi commented on Mar 15

I'm adding exportCSV output to an existing report. The CSV export is added thousand separators in all number values. This does not happen with the normal report, nor does it happen with the PDF export that uses the same datastore. I added a pipe to \koolreport\processes\ColumnMeta to add an empty string as the separator (https://www.koolreport.com/forum/topics/2559), however, this does not seem to have any effect. I added an enclosure around the columns to illustrate this issue. Any help is appreciated. Thanks.

$report = new SalesClosedReport(array(
        'startDate' => $startDate,
        'repsId' => $repsId,
        'groupby' => $groupby,
        'endDate' => $endDate,
        'showAllUsers' => $showAllUsers
    ));
    $report->run();
    $report->exportToCSV(
        array(
            "dataStores" => array(
                "sales_report" => [
                    #"separator" => ",", // default separator = "," i.e. comma
                    "enclosure" => "\"", // default general enclosure = "" i.e. empty string
                    #"enclosure" => ["(", ")"], // all enclosure property could be a 2 element array
                    'useCustomColumnEnclosure' => 1, // default = 0
                ],
            ),

            "useLocalTempFolder" => true,
            "BOM" => false, // default bom = false
            "buffer" => 1000, // unit: KB ~ 1000 bytes. Default buffer = 1000 KB
        ),
    )
        ->toBrowser("sales-report.csv");

from SalesClosedReport.class.php

->pipe(new \koolreport\processes\ColumnMeta([
                    "cid" => [
                        "type" => "number",
                        "decimals" => 0,
                        "thousandSeperator" => ""
                    ]
                    ]))
Michael Boccardi commented on Mar 18

Hi - Any help?

Sebastian Morales commented on Mar 20

Sorry for the delayed reply. Please try

    "thousandSeparator" => ""

instead of:

    "thousandSeperator" => ""

to see if it works.

Another solution is to use column meta "type" => "string" to stop the numerical formatting completely.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Excel