Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.1K
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda