PHP code example of marshallgosling / php-excel
1. Go to this page and download the library: Download marshallgosling/php-excel 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/ */
marshallgosling / php-excel example snippets
use Nathan\PHPExcel\IOFactory;
use Nathan\PHPExcel\PHPExcel;
function createObj()
{
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator($creator)
->setLastModifiedBy($creator)
->setTitle($title)
->setSubject($subject)
->setDescription($description)
->setKeywords($keywords)
->setCategory($category);
}
function loadTemplate($file)
{
$objPHPExcel = IOFactory::load($file);
}
function outputFile($filename, $mode='file')
{
$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel2007');
if($mode == 'stream') {
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=1920');
$objWriter->save('php://output');
exit;
}
if($mode == 'file') {
$objWriter->save($filename);
}
}