How do I download the report with comma separated value instead of semicolon separated?

Hi,

How do I download the report with comma separated value?

Currently, Pimcore is using semi-colon as a default delimiter in the export csv under Report.
I want to change the delimiter from semi-colon to comma. Is there any way around to change the delimitor?

Thanks,
Shashi

@sshekhar09
Override doExportAction function of DataObjectHelperOverrideController and assign $delimiter variable like below:-

$delimiter = $settings[‘delimiter’] ? $settings[‘delimiter’] : ‘,’;

for marketing & report override
downloadCsvAction and pass default comma as a delimiter.

Thanks,
Gobind Kumar Chauhan

Hi @sshekhar09 currently ‘;’ is hard coded in csv export.You will have extend/override the code.

/**
 * @Route("/download-csv", name="pimcore_admin_reports_customreport_downloadcsv", methods={"GET"})
 *
 * @param Request $request
 *
 * @return BinaryFileResponse
 */
public function downloadCsvAction(Request $request)
{
    $this->checkPermission('reports');

    set_time_limit(300);

    $sort = $request->get('sort');
    $dir = $request->get('dir');
    $filters = ($request->get('filter') ? json_decode($request->get('filter'), true) : null);
    $drillDownFilters = $request->get('drillDownFilters', null);
    $includeHeaders = $request->get('headers', false);

    $config = CustomReport\Config::getByName($request->get('name'));

    $columns = $config->getColumnConfiguration();
    $fields = [];
    $headers = [];
    foreach ($columns as $column) {
        if ($column['export']) {
            $fields[] = $column['name'];
            $headers[] = !empty($column['label']) ? $column['label'] : $column['name'];
        }
    }

    $configuration = $config->getDataSourceConfig();
    //if many rows returned as an array than use the first row. Fixes: #782
    $configuration = is_array($configuration)
        ? $configuration[0]
        : $configuration;

    $adapter = CustomReport\Config::getAdapter($configuration, $config);
    $result = $adapter->getData($filters, $sort, $dir, null, null, $fields, $drillDownFilters);

    $exportFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . '/report-export-' . uniqid() . '.csv';
    @unlink($exportFile);

    $fp = fopen($exportFile, 'w');

    if ($includeHeaders) {
        fputcsv($fp, $headers, ';'); // change this to ','
    }

    foreach ($result['data'] as $row) {
        fputcsv($fp, array_values($row), ';'); // change this to ','
    }

    fclose($fp);

    $response = new BinaryFileResponse($exportFile);
    $response->headers->set('Content-Type', 'text/csv; charset=UTF-8');
    $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'export.csv');
    $response->deleteFileAfterSend(true);

    return $response;
}

I’ll also suggest you to create an issue in git-hub for the same.If resolved it will be available in the future releases.