Export document to excel with PHP

0

Is it possible to export a table from a site to an excel document? But with the new format, I've seen codes similar to this:

<?php
  header('Content-type: application/vnd.ms-excel');
  header("Content-Disposition: attachment; filename=InformeVentas.xls");
?>

But I have tried it and it exports to the excel format 97-2003. Is there any way to make it with the new (. Xlsx) format but without using libraries such as PHPExcel or PHPSpreadSheet, only using the php code.

    
asked by M4uriXD 24.04.2018 в 23:22
source

1 answer

1

I must tell you that I have not found such a form, I recommend you use PhpSpreadSheet

easy and simple example:

<?php

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');

$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');
    
answered by 24.04.2018 / 23:38
source