Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
How to remove double quotations from exported csv file

I'm using Laravel 5.8 and I have added Maatwebsite package for exporting CSV files from a database table.

And here is my exported class:

class ConfirmedExport implements FromCollection, WithHeadings
{
    public function headings():array{
        return [
   
        ];
    }

    public function collection()
    {
        return collect(WithdrawWallet::getData());
    }
}

And the result looks like this:

"123456789","2100","Desc","lname","fname"

But I need to remove double quotations (" ") from the words, so the expected result looks like this:

123456789,2100,Desc,lname,fname

So how to do that?


UPDATE #1:

I just tried this code for Export Class:

namespace App\Exports;

use App\WithdrawWallet;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;

class ConfirmedExport implements FromCollection, WithHeadings
{
    public function headings():array{
        return [
   
        ];
    }

    public function collection()
    {
        return collect(WithdrawWallet::getData());
    }
    
    public function getCsvSettings(): array
    {
        return [
            'enclosure' => ''
        ];
    }
}

And it successfully removes the " " from the last element (which is: 123456789), but still shows the " " for the other ones!

enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

@nagidi after you publish the config you may change this in the settings.

  1. Run following command:

    php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
    
  2. Remove " (double quote) from 'enclosure' in config/excel.php

     'exports' => [
         'csv' => [
             'enclosure' => '', // was '"'
             // other settings
         ],
     ],
    

Now your csv export values doesn't contain the " enclosure anymore.

If you want to change this setting per Export, you can implement the WithCustomCsvSettings Concern and add the getCsvSettings method to your ConfirmedExport class:

use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;

class ConfirmedExport implements WithCustomCsvSettings
{
    // other code

    public function getCsvSettings(): array
    {
        return [
            'enclosure' => ''
        ];
    }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!