PHP code example of everton-hilario / csv-hilario

1. Go to this page and download the library: Download everton-hilario/csv-hilario library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

everton-hilario / csv-hilario example snippets


use CsvHilario\ExportCsv\ExportCsv;
//dados com o conteúdo do arquivo
$data = [
	["a" => "teste1", "b" => "teste2", "c" => "teste3"],
	["a" => "teste4", "b" => "teste5", "c" => "teste6"]
];
$csv = new ExportCsv;
$csv->setData($data);
$csv->export();

use CsvHilario\ExportCsv\ExportCsv;
//dados com o conteúdo do arquivo
$data = [
	["teste1", "teste2", "teste3"],
	["teste4", "teste5", "teste6"]
];
//dados do topo da planilha, títulos das colunas
$header = ["a", "b", "c"];
$csv = new ExportCsv;
$csv->setData($data);
$csv->setHeader($header);
$csv->setDelimiter(";");
$csv->setFileName("gremio-file");
$csv->setOutput("D");
$csv->export();

use CsvHilario\ExportCsv\ExportCsv;
//dados com o conteúdo do arquivo
$data = [
	["teste1", "teste2", "teste3"],
	["teste4", "teste5", "teste6"]
];
//dados do topo da planilha, títulos das colunas
$header = ["a", "b", "c"];
$csv = new ExportCsv;
$csv->setData($data);
$csv->setHeader($header);
$csv->setDelimiter(";");
$csv->setFileName("gremio-file");
$csv->setOutput("S", "directory/");
$csv->export();