public function __construct(Workbook $workbook) { $this->workbook = $workbook; $this->workbook->setActiveSheetIndex(0); $this->workbook->getActiveSheet()->setTitle($this->workbook->getProperties()->getTitle()); Cell::setValueBinder(new ForceCellAsString()); Shared_Font::setAutoSizeMethod(Shared_Font::AUTOSIZE_METHOD_EXACT); }
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ /** Error reporting */ error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />'); /** PHPExcel */ require_once dirname(__FILE__) . '/../src/Bootstrap.php'; // Set timezone echo date('H:i:s'), " Set timezone", EOL; date_default_timezone_set('UTC'); // Set value binder echo date('H:i:s'), " Set value binder", EOL; \PHPExcel\Cell::setValueBinder(new \PHPExcel\Cell\AdvancedValueBinder()); // Create new PHPExcel object echo date('H:i:s'), " Create new PHPExcel object", EOL; $objPHPExcel = new \PHPExcel\Spreadsheet(); // Set document properties echo date('H:i:s'), " Set document properties", EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file"); // Set default font echo date('H:i:s'), " Set default font", EOL; $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial'); $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10); // Set column widths echo date('H:i:s'), " Set column widths", EOL; $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(14); // Add some data, resembling some different data types