livewire-powergrid icon indicating copy to clipboard operation
livewire-powergrid copied to clipboard

[3.x] Add CSV Export Options: Separator & Delimiter

Open dansysanalyst opened this issue 3 years ago • 1 comments

⚡ PowerGrid ⚡ Pull Request

Welcome and thank you for your interest in contributing to our project!. You must use this template to submit a Pull Request or it will not be accepted.

💡 Please complete this template to submit a Pull Request, we cannot accept incomplete Pull Requests.

Guidelines

🗒️ Please read the Contributing Guide and follow all steps listed there.

✍️ Give this PR a meaningful title.

📣 Describe your PR details below.

Pull Request Information

Motivation

  • [ ] Bug fix
  • [X] New feature
  • [ ] Breaking change

Related Issue(s)

This PR Fixes the Issue https://github.com/Power-Components/livewire-powergrid/issues/623.

Description

This Pull Request adds the possibility to set the separator and field delimiter when exporting to CSV.

    public function setUp(): array
    {
        $this->showCheckBox();

        return [
            Exportable::make('export')
                ->csvSeparator('|')
                ->csvDelimiter('@')
                ->type(Exportable::TYPE_CSV),
        ];
    }

Resulting in:

ID|Prato
1|@Pastel de Nata@

Instead of the default:

ID,Prato
1,"Pastel de Nata"

This can be useful if the CSV exported by PowerGrid will be imported in some other software with different requirements.

Contribution Guide

Documentation

This PR requires Documentation update?

  • [ ] Yes
  • [ ] No
  • [X] I have already submitted a Documentation pull request.

dansysanalyst avatar Sep 12 '22 12:09 dansysanalyst

DOC PR: https://github.com/Power-Components/powergrid-doc/pull/51

dansysanalyst avatar Sep 12 '22 12:09 dansysanalyst