日期:2014-05-17 浏览次数:20712 次
<?php /** * PHPExcel * * Copyright (C) 2006 - 2007 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel * @package PHPExcel * @copyright Copyright (c) 2006 - 2007 PHPExcel ( http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/lgpl.txt LGPL * @version 1.5.0, 2007-10-23 */ /** Error reporting */ error_reporting(E_ALL); /** Include path **/ set_include_path(get_include_path() . PATH_SEPARATOR . ‘../Classes/’); /** PHPExcel */ include ‘PHPExcel.php’; /** PHPExcel_Writer_Excel2007 */ include ‘PHPExcel/Writer/Excel2007.php’; // Create new PHPExcel object echo date(’H:i:s’) . ” Create new PHPExcel object\n”; $objPHPExcel = new PHPExcel(); // Set properties echo date(’H:i:s’) . ” Set properties\n”; $objPHPExcel->getProperties()->setCreator(”Maarten Balliauw”); $objPHPExcel->getProperties()->setLastModifiedBy(”Maarten Balliauw”); $objPHPExcel->getProperties()->setTitle(”Office 2007 XLSX Test Document”); $objPHPExcel->getProperties()->setSubject(”Office 2007 XLSX Test Document”); $objPHPExcel->getProperties()->setDescrīption(”Test document for Office 2007 XLSX, generated using PHP classes.”); $objPHPExcel->getProperties()->setKeywords(”office 2007 openxml php”); $objPHPExcel->getProperties()->setCategory(”Test result file”); // Add some data echo date(’H:i:s’) . ” Add some data\n”; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setCellValue(’A1′, ‘Hello’); $objPHPExcel->getActiveSheet()->setCellValue(’B2′, ‘world!’); $objPHPExcel->getActiveSheet()->setCellValue(’C1′, ‘Hello’); $objPHPExcel->getActiveSheet()->setCellValue(’D2′, ‘world!’); // Rename sheet echo date(’H:i:s’) . ” Rename sheet\n”; $objPHPExcel->getActiveSheet()->setTitle(’Simple’); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file echo date(’H:i:s’) . ” Write to Excel2007 format\n”; $objWrite