PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Craig Smith   Basic Excel   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Basic Excel
Import and export Excel files to XLS, XLSX and CSV
Author: By
Last change: Update of example.php
Date: 6 months ago
Size: 525 bytes
 

Contents

Class file image Download
<?php

require_once('BasicExcel/Reader.php');
\
BasicExcel\Reader::registerAutoloader();


$data = array(
    array(
'Nr.', 'Name', 'E-Mail'),
    array(
1, 'Jane Smith', 'jane.smith@fakemail.com'),
    array(
2, 'John Smith', 'john.smith@fakemail.com'));

try {
   
$csvwriter = new \BasicExcel\Writer\Csv(); //or \Xls || \Xlsx
   
$csvwriter->fromArray($data);
   
//$csvwriter->writeFile('myfilename.csv');
    //OR
   
$csvwriter->download('myfilename.csv');
} catch (
Exception $e) {
    echo
$e->getMessage();
    exit;
}