PHPEXCEL Àà¿â,¹¦ÄÜÇ¿´ó,Ö§³Öwin Excel2003 ,Win Excel2007.
http://www.codeplex.com/PHPExcel
save("xxx.xls"); ?> -------------------------------------------------------------------------------------- //ÉèÖÃPHPExcelÀà¿âµÄinclude path set_include_path('.' . PATH_SEPARATOR . 'D:\Zeal\PHP_LIBS' . PATH_SEPARATOR . get_include_path()); /** * ÒÔÏÂÊÇʹÓÃʾÀý£¬¶ÔÓÚÒÔ //// ¿ªÍ·µÄÐÐÊDz»Í¬µÄ¿ÉÑ¡·½Ê½£¬Çë¸ù¾Ýʵ¼ÊÐèÒª * ´ò¿ª¶ÔÓ¦ÐеÄ×¢ÊÍ¡£ * Èç¹ûʹÓà Excel5 £¬Êä³öµÄÄÚÈÝÓ¦¸ÃÊÇGBK±àÂë¡£ */ require_once 'PHPExcel.php' ; // uncomment ////require_once 'PHPExcel/Writer/Excel5.php'; // ÓÃÓÚÆäËûµÍ°æ±¾xls // or ////require_once 'PHPExcel/Writer/Excel2007.php'; // ÓÃÓÚ excel-2007 ¸ñʽ // ´´½¨Ò»¸ö´¦Àí¶ÔÏóʵÀý $objExcel = new PHPExcel(); // ´´½¨Îļþ¸ñʽдÈë¶ÔÏóʵÀý, uncomment ////$objWriter = new PHPExcel_Writer_Excel5($objExcel); // ÓÃÓÚÆäËû°æ±¾¸ñʽ // or ////$objWriter = new PHPExcel_Writer_Excel2007($objExcel); // ÓÃÓÚ 2007 ¸ñʽ //$objWriter->setOffice2003Compatibility(true); //************************************* //ÉèÖÃÎĵµ»ù±¾ÊôÐÔ $objProps = $objExcel ->getProperties(); $objProps ->setCreator("Zeal Li" ); $objProps ->setLastModifiedBy("Zeal Li" ); $objProps ->setTitle("Office XLS Test Document" ); $objProps ->setSubject("Office XLS Test Document, Demo" ); $objProps ->setDescription("Test document, generated by PHPExcel." ); $objProps ->setKeywords("office excel PHPExcel" ); $objProps ->setCategory("Test" ); //************************************* //ÉèÖõ±Ç°µÄsheetË÷Òý£¬ÓÃÓÚºóÐøµÄÄÚÈݲÙ×÷¡£ //Ò»°ãÖ»ÓÐÔÚʹÓöà¸ösheetµÄʱºò²ÅÐèÒªÏÔʾµ÷Óᣠ//ȱʡÇé¿öÏ£¬PHPExcel»á×Ô¶¯´´½¨µÚÒ»¸ösheet±»ÉèÖÃSheetIndex=0 $objExcel ->setActiveSheetIndex(0); $objActSheet = $objExcel ->getActiveSheet(); //ÉèÖõ±Ç°»î¶¯sheetµÄÃû³Æ $objActSheet ->setTitle('²âÊÔSheet' ); //************************************* //ÉèÖõ¥Ôª¸ñÄÚÈÝ // //ÓÉPHPExcel¸ù¾Ý´«ÈëÄÚÈÝ×Ô¶¯Åжϵ¥Ôª¸ñÄÚÈÝÀàÐÍ $objActSheet ->setCellValue('A1' , '×Ö·û´®ÄÚÈÝ' ); // ×Ö·û´®ÄÚÈÝ $objActSheet ->setCellValue('A2' , 26); // ÊýÖµ $objActSheet ->setCellValue('A3' , true); // ²¼¶ûÖµ $objActSheet ->setCellValue('A4' , '=SUM(A2:A2)' ); // ¹«Ê½ //ÏÔʽָ¶¨ÄÚÈÝÀàÐÍ $objActSheet ->setCellValueExplicit('A5' , '847475847857487584' , PHPExcel_Cell_DataType::TYPE_STRING); //ºÏ²¢µ¥Ôª¸ñ $objActSheet ->mergeCells('B1:C22' ); //·ÖÀëµ¥Ôª¸ñ $objActSheet ->unmergeCells('B1:C22' ); //************************************* //ÉèÖõ¥Ôª¸ñÑùʽ // //ÉèÖÿí¶È $objActSheet ->getColumnDimension('B' )->setAutoSize(true); $objActSheet ->getColumnDimension('A' )->setWidth(30); $objStyleA5 = $objActSheet ->getStyle('A5' ); //ÉèÖõ¥Ôª¸ñÄÚÈݵÄÊý×Ö¸ñʽ¡£ // //Èç¹ûʹÓÃÁË PHPExcel_Writer_Excel5 À´Éú³ÉÄÚÈݵĻ°£¬ //ÕâÀïÐèҪעÒ⣬ÔÚ PHPExcel_Style_NumberFormat ÀàµÄ const ±äÁ¿¶¨ÒåµÄ //¸÷ÖÖ×Ô¶¨Òå¸ñʽ»¯·½Ê½ÖУ¬ÆäËüÀàÐͶ¼¿ÉÒÔÕý³£Ê¹Ó㬵«µ±setFormatCode //Ϊ FORMAT_NUMBER µÄʱºò£¬Êµ¼Ê³öÀ´µÄЧ¹û±»Ã»ÓаѸñʽÉèÖÃΪ"0"¡£ÐèÒª //ÐÞ¸Ä PHPExcel_Writer_Excel5_Format ÀàÔ´´úÂëÖÐµÄ getXf($style) ·½·¨£¬ //ÔÚ if ($this->_BIFF_version == 0x0500) { £¨µÚ363Ðи½½ü£©Ç°ÃæÔö¼ÓÒ» //ÐдúÂë: //if($ifmt === '0') $ifmt = 1; // //ÉèÖøñʽΪPHPExcel_Style_NumberFormat::FORMAT_NUMBER£¬±ÜÃâijЩ´óÊý×Ö //±»Ê¹ÓÿÆѧ¼ÇÊý·½Ê½ÏÔʾ£¬ÅäºÏÏÂÃæµÄ setAutoSize ·½·¨¿ÉÒÔÈÃÿһÐеÄÄÚÈÝ //¶¼°´ÔʼÄÚÈÝÈ«²¿ÏÔʾ³öÀ´¡£ $objStyleA5 ->getNumberFormat() ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER); //ÉèÖÃ×ÖÌå $objFontA5 = $objStyleA5 ->getFont(); $objFontA5 ->setName('Courier New' ); $objFontA5 ->setSize(10); $objFontA5 ->setBold(true); $objFontA5 ->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objFontA5 ->getColor()->setARGB('FF999999' ); //ÉèÖöÔÆ뷽ʽ $objAlignA5 = $objStyleA5 ->getAlignment(); $objAlignA5 ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objAlignA5 ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); //ÉèÖñ߿ò $objBorderA5 = $objStyleA5 ->getBorders(); $objBorderA5 ->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objBorderA5 ->getTop()->getColor()->setARGB('FFFF0000' ); // color $objBorderA5 ->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objBorderA5 ->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objBorderA5 ->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); //ÉèÖÃÌî³äÑÕÉ« $objFillA5 = $objStyleA5 ->getFill(); $objFillA5 ->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objFillA5 ->getStartColor()->setARGB('FFEEEEEE' ); //´ÓÖ¸¶¨µÄµ¥Ôª¸ñ¸´ÖÆÑùʽÐÅÏ¢. $objActSheet ->duplicateStyle($objStyleA5 , 'B1:C22' ); //************************************* //Ìí¼ÓͼƬ $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing ->setName('ZealImg' ); $objDrawing ->setDescription('Image inserted by Zeal' ); $objDrawing ->setPath('./zeali.net.logo.gif' ); $objDrawing ->setHeight(36); $objDrawing ->setCoordinates('C23' ); $objDrawing ->setOffsetX(10); $objDrawing ->setRotation(15); $objDrawing ->getShadow()->setVisible(true); $objDrawing ->getShadow()->setDirection(36); $objDrawing ->setWorksheet($objActSheet ); //Ìí¼ÓÒ»¸öеÄworksheet $objExcel ->createSheet(); $objExcel ->getSheet(1)->setTitle('²âÊÔ2' ); //±£»¤µ¥Ôª¸ñ $objExcel ->getSheet(1)->getProtection()->setSheet(true); $objExcel ->getSheet(1)->protectCells('A1:C22' , 'PHPExcel' ); //************************************* //Êä³öÄÚÈÝ // $outputFileName = "output.xls" ; //µ½Îļþ ////$objWriter->save($outputFileName); //or //µ½ä¯ÀÀÆ÷ ////header("Content-Type: application/force-download"); ////header("Content-Type: application/octet-stream"); ////header("Content-Type: application/download"); ////header('Content-Disposition:inline;filename="'.$outputFileName.'"'); ////header("Content-Transfer-Encoding: binary"); ////header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); ////header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); ////header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); ////header("Pragma: no-cache"); ////$objWriter->save('php://output'); ?>
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ