diff --git a/Classes/PHPExcel/Writer/HTML.php b/Classes/PHPExcel/Writer/HTML.php index 7a41bb5..5dcb998 100644 --- a/Classes/PHPExcel/Writer/HTML.php +++ b/Classes/PHPExcel/Writer/HTML.php @@ -656,6 +656,22 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $imageData . '" border="0" />'; $html .= ''; } + } elseif ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) { + if ($drawing->getCoordinates() != $coordinates) { + continue; + } + ob_start(); // Let's start output buffering. + imagepng($drawing->getImageResource()); // This will normally output the image, but because of ob_start(), it won't. + $contents = ob_get_contents(); // Instead, output above is saved to $contents + ob_end_clean(); // End the output buffer. + + $dataUri = "data:image/jpeg;base64," . base64_encode($contents); + + // Because of the nature of tables, width is more important than height. + // max-width: 100% ensures that image doesnt overflow containing cell + // width: X sets width of supplied image. + // As a result, images bigger than cell will be contained and images smaller will not get stretched + $html .= ''; } } diff --git a/Examples/25inmemoryimage.php b/Examples/25inmemoryimage.php index 167a861..6c3b0b8 100644 --- a/Examples/25inmemoryimage.php +++ b/Examples/25inmemoryimage.php @@ -75,9 +75,15 @@ $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; +echo date('H:i:s') , " Write to HTML format" , EOL; +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML'); +$objWriter->save(str_replace('.php', '.html', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.html', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; + + // Echo memory peak usage echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; // Echo done echo date('H:i:s') , " Done writing file" , EOL; -echo 'File has been created in ' , getcwd() , EOL; +echo 'Files have been created in ' , getcwd() , EOL; diff --git a/changelog.txt b/changelog.txt index 4d1605b..2b7c4a7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -31,6 +31,7 @@ Planned for 1.8.2 - Bugfix: (MBaker) Work Item GH-554 - Whitespace after toRichTextObject() - Feature: (MBaker) - Initial implementation of SUMIFS() function - Feature: (MBaker) - Additional codepages +- Feature: (Tomino2112) Work Item GH-808 - MemoryDrawing not working in HTML writer 2015-04-30 (v1.8.1):