1. Go to this page and download the library: Download eclipxe/xlsxexporter 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/ */
eclipxe / xlsxexporter example snippets
use Eclipxe\XlsxExporter;
use Eclipxe\XlsxExporter\CellTypes;
use Eclipxe\XlsxExporter\Column;
use Eclipxe\XlsxExporter\Columns;
use Eclipxe\XlsxExporter\Providers\ProviderArray;
use Eclipxe\XlsxExporter\Style;
use Eclipxe\XlsxExporter\Styles\Format;
use Eclipxe\XlsxExporter\WorkBook;
use Eclipxe\XlsxExporter\WorkSheet;
use Eclipxe\XlsxExporter\WorkSheets;
use Eclipxe\XlsxExporter\Exceptions\XlsxException;
// create a simple array as example
$provider = new ProviderArray([
['first_name' => 'Charles', 'amount' => 1234.561, 'visit' => strtotime('2014-01-13 13:14:15'), 'check' => 1],
['first_name' => 'Foo', 'amount' => 6543.219, 'visit' => strtotime('2014-12-31 23:59:59'), 'check' => 0],
]);
// create some special formats
$formatNumber2Decimals = new Style(['format' => ['code' => Format::FORMAT_COMMA_2DECS]]);
$formatDateTime = new Style(['format' => ['code' => Format::FORMAT_DATE_YMDHM]]);
$formatYesNo = new Style(['format' => ['code' => Format::FORMAT_YESNO]]);
// create the workbook with all the information
$workbook = new WorkBook(
new WorkSheets(
new WorkSheet('sheet01', $provider, new Columns(
new Column('first_name', 'Name'),
new Column('amount', 'Amount', CellTypes::NUMBER, $formatNumber2Decimals),
new Column('visit', 'Visit', CellTypes::DATETIME, $formatDateTime),
new Column('check', 'Check', CellTypes::BOOLEAN, $formatYesNo),
)),
)
);
// call the write process
try{
XlsxExporter::save($workbook, __DIR__ . '/result.xlsx');
} catch (XlsxException $exception) {
echo 'Export error: ', $exception->getMessage(), PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.