From 4d9258c9e17d082f418a7c8cbf331531abf14dbf Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 27 Apr 2013 13:42:14 +0100 Subject: [PATCH] Modified some of the examples to show rich text and additional download headers that might be needed --- Examples/01simple-download-xls.php | 8 ++++++++ Examples/02types-xls.php | 11 +++++++++++ Examples/02types.php | 13 +++++++++++++ 3 files changed, 32 insertions(+) diff --git a/Examples/01simple-download-xls.php b/Examples/01simple-download-xls.php index c1d670dc..986e3ae6 100644 --- a/Examples/01simple-download-xls.php +++ b/Examples/01simple-download-xls.php @@ -75,6 +75,14 @@ $objPHPExcel->setActiveSheetIndex(0); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="01simple.xls"'); header('Cache-Control: max-age=0'); +// If you're serving to IE 9, then the following may be needed +header('Cache-Control: max-age=1'); + +// If you're serving to IE over SSL, then the following may be needed +header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past +header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified +header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 +header ('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); diff --git a/Examples/02types-xls.php b/Examples/02types-xls.php index 905dc9d1..53d6cc52 100644 --- a/Examples/02types-xls.php +++ b/Examples/02types-xls.php @@ -109,6 +109,17 @@ $objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCod $objPHPExcel->getActiveSheet()->setCellValue('A12', 'NULL') ->setCellValue('C12', NULL); +$objRichText = new PHPExcel_RichText(); +$objRichText->createText('你好 '); +$objPayable = $objRichText->createTextRun('你 好 吗?'); +$objPayable->getFont()->setBold(true); +$objPayable->getFont()->setItalic(true); +$objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) ); + +$objRichText->createText(', unless specified otherwise on the invoice.'); + +$objPHPExcel->getActiveSheet()->setCellValue('A13', 'Rich Text') + ->setCellValue('C13', $objRichText); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); diff --git a/Examples/02types.php b/Examples/02types.php index a66af905..6a5ea9d4 100644 --- a/Examples/02types.php +++ b/Examples/02types.php @@ -109,7 +109,20 @@ $objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCod $objPHPExcel->getActiveSheet()->setCellValue('A12', 'NULL') ->setCellValue('C12', NULL); +$objRichText = new PHPExcel_RichText(); +$objRichText->createText('你好 '); +$objPayable = $objRichText->createTextRun('你 好 吗?'); +$objPayable->getFont()->setBold(true); +$objPayable->getFont()->setItalic(true); +$objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) ); + +$objRichText->createText(', unless specified otherwise on the invoice.'); + +$objPHPExcel->getActiveSheet()->setCellValue('A13', 'Rich Text') + ->setCellValue('C13', $objRichText); + + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);