【发布时间】:2017-03-15 03:45:52
【问题描述】:
我很努力,只想在 A1 单元格中显示条形码图像。它在 html 中运行良好。但不是在 PhpExcel 中。提前致谢。
$generator = new BarcodeGeneratorPNG();
$wizard = new PHPExcel_Helper_HTML();
$cellText = '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode('081231723837', $generator::TYPE_CODE_128)) . '">';
$richText = $wizard->toRichTextObject($cellText);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $richText);
【问题讨论】:
-
我建议阅读"in memory" images with PHPExcel,而不是试图假设世界上的一切都只是html标记
-
感谢您使用 html 编写器突出显示错误;富文本对象中的 html 标记应转义以防止其显示为 html
-
非常感谢,但我已经得到答案了。