usmanhalalit / laracsv

CSV files from Eloquent model in seconds - a Laravel package.
MIT License
605 stars 59 forks source link

delimiter #30

Closed jplajpla23 closed 5 years ago

jplajpla23 commented 5 years ago

I can choose the delimiter, the default is the comma (,) but I wanted the semicolon (;)

usmanhalalit commented 5 years ago

@jplajpla23 You can set a delimiter, please check https://github.com/usmanhalalit/laracsv/blob/master/tests/Laracsv/ExportTest.php#L223 . This is a LaraCSV 2.0 example, so please make sure to update or use getCsv() instead of getWriter().

juanmanavarro commented 5 years ago

@usmanhalalit can you explain please? thank you

valigton commented 3 years ago

@usmanhalalit can you explain please? thank you

Just set de delimiter before build.

( I know it's old issue but, if someone needs... )

$csv = new \Laracsv\Export();

$csv->getWriter()->setDelimiter(";");

$csv->build($collection, [
    'field1',
    'field2'
]);