mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-25 14:56:04 +03:00
Feature: (Tomino2112) Work Item GH-808 - MemoryDrawing not working in HTML writer
Manual merge of Pull Request
This commit is contained in:
parent
352e6ea5cc
commit
39d8b8f57a
@ -656,6 +656,22 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
||||
$imageData . '" border="0" />';
|
||||
$html .= '</div>';
|
||||
}
|
||||
} 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 .= '<img src="'.$dataUri.'" style="max-width:100%;width:'.$drawing->getWidth().'px;" />';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user