PHP导入导出Excel方法
sp; // 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”; $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); $objWriter->save(str_replace(’.php’, ‘.xlsx’, __FILE__)); // Echo done echo date(’H:i:s’) . ” Done writing file.\r\n”;
2、使用pear的Spreadsheet_Excel_Writer类
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |