我努力了,只想在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);
答案 0 :(得分:0)
尝试一下:
$filepath = 'barcode.png';
$text = '1234567890123';
$size = "80";
$orientation = "horizontal";
$code_type = "code128";
$print = "true";
$sizefactor = "0.8";
barcode( $filepath,$text, $size, $orientation, $code_type, $print, $sizefactor );
$imgBarcode = imagecreatefrompng('bar_code.png');
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setDescription('barcode');
$objDrawing->setImageResource($imgBarcode);
$objDrawing->setHeight(100);
$objDrawing->setCoordinates('A1');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());