疯狂Erlangyueming.blog.chinaunix.net
yueming
全部博文(921)
mnesia(1)
Flex框架(0)
mxml(0)
AS3(0)
MongoDB(1)
NOSQL(4)
关系型(Mysql)(0)
redis(49)
gevent(2)
Django(7)
Twisted(94)
wxpython(0)
Magento文档翻译(0)
C/C++(4)
AMP(9)
平面&三维设计(0)
网页三剑客&&html(0)
asp&&sqlserver(0)
2020年(1)
2019年(3)
2018年(3)
2017年(6)
2016年(47)
2015年(72)
2014年(25)
2013年(72)
2012年(125)
2011年(182)
2010年(42)
2009年(14)
2008年(85)
2007年(89)
2006年(155)
无色T恤
13790913
wanglian
swsw23
无赖皮肤
zhuqing_
qq203586
hk_sean
jiannma
saberwen
nowhere
__s1ng我
kubernet
wuhanyan
weiyunyi
refreshR
格伯纳
yuankk8
分类:
2008-06-18 14:54:34
<?phpset_include_path('/var/www/myproject');require_once('PHPExcel.php');require_once('PHPExcel/Writer/Excel2007.php');$php_excel->getProperties()->setCreator("Scott");$php_excel->getProperties()->setLastModifiedBy("Scott");$php_excel->getProperties()->setTitle("My Project");$php_excel->getProperties()->setSubject("My Project");$php_excel->getProperties()->setDescription("Fun Project"); $sheet = $php_excel->setActiveSheetIndex(0);$sheet = $php_excel->getActiveSheet(); $sheet->setCellValue('A1', 'Name');$sheet->getStyle('A1')->getFont()->setBold(true);$sheet->setCellValue('B1', 'Price');$sheet->getStyle('B1')->getFont()->setBold(true); $count = 2; foreach($objects as $object) { $sheet->setCellValue('A'.$count, $object->getName()); $cell->setDataType(PHPExcel_Cell_DataType::TYPE_NUMERIC); $style=$sheet->getStyle('B'.$count); $style->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); $sheet->setCellValue('B'.$count, $object->getPrice()); ++$count;} $sheet->getColumnDimension('A')->setAutoSize(true);$sheet->getColumnDimension('B')->setAutoSize(true); $writer = new PHPExcel_Writer_Excel2007($php_excel);$writer->save("/tmp/excel_file.xlsx"); header("Cache-Control: private");header("Content-type: application/xlsx");header("Content-Disposition: attachment; filename=\"general_registration_list.xlsx\"");header('Cache-Control: maxage=3600'); //Adjust maxage appropriatelyheader('Content-Length: '.filesize('/tmp/excel_file.xlsx'));header('Pragma: public');readfile("/tmp/excel_file.xlsx");flush();?>
上一篇:PHPEXCEL使用小结
下一篇:mysql错误:……is marked as crashed and should be repai
登录 注册