PHP code example of genesisaplicaciones / genesis-php-tools

1. Go to this page and download the library: Download genesisaplicaciones/genesis-php-tools 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/ */

    

genesisaplicaciones / genesis-php-tools example snippets


// this way you get the report with the same data you pass and force the download
$template = new GenesisPhpTools\SpreadSheetTemplate(); // Initialice the class with the default configuration
$template->generate_file(
    "usuarios", //the report name
    $datos_reporte, //report data
    true, // force the download of the file
);

// this way you get the report with excluded and renamed columns, a logo, custom color and correct file metadata

$doc_config = [
    'owner_info' => $this->session->razon_social,
    'logo' => 'assets/panel/img/logo.png',
    'solution_name' => 'TimbraXML',
    'table_color' => 'FF0C77C2'
];

$columns_config = [ 
    "excluded" => ['id_cuenta', 'id_usuario'] ,
    "renamed" => [
        "control_access" => "Acceso al portal",
        "panel_access" => "Nivel de acceso",
        "vista" => "Tipo de facturacion"
    ]
];

$template = new GenesisPhpTools\SpreadSheetTemplate($doc_config); // Initialice the class with the default configuration
$my_file = $template->generate_file(
    "usuarios", //the report name
    $datos_reporte, //report data
    false, // don't force the download of the file, so you can manipulate it
    $columns_config,
);

return_data(base64_encode($my_file)); // return the data like you want, in this case in base64 inside a json response