Skip to content

Commit

Permalink
hotfix add csv delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezzzhak committed Aug 24, 2018
1 parent 6c89681 commit b5c0a10
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/services/ExportService.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace kak\widgets\grid\services;

use Box\Spout\Writer\CSV\Writer as CsvWriter;
use kak\widgets\grid\interfaces\ExportType;
use kak\widgets\grid\iterators\DataProviderBatchIterator;
use kak\widgets\grid\iterators\SourceIterator;
Expand Down Expand Up @@ -40,6 +41,9 @@ class ExportService
*/
public $limit = null;

/** @var string */
public $csvFieldDelimiter = ';';

public function run()
{
try {
Expand All @@ -65,7 +69,7 @@ public function run()
$writer->addRow($data);
}
$writer->close();
\Yii::$app->end();
exit;
}

/**
Expand All @@ -79,11 +83,14 @@ protected function getFileName()
$type = isset($types[$this->type]) ? $types[$this->type] : $this->type;
return Yii::$app->controller->id . '-' . Yii::$app->controller->action->id . '-' . date('Y-m-d-Hi') . '.' . $type;
}



protected function getWriter()
{
return writer\WriterFactory::create($this->type);
$result = writer\WriterFactory::create($this->type);
if ($result instanceof CsvWriter) {
$result->setFieldDelimiter($this->csvFieldDelimiter);
}
return $result;
}


Expand Down

0 comments on commit b5c0a10

Please sign in to comment.