2

我正在尝试创建 Excel 文件并从网页向其附加数据。Excel 文件已正确创建并且数据也保存在其中,但是当我尝试再次加载文件并将数据附加到它时。它给出了一个致命错误

/home/timespk/public_html/Classes/PHPExcel/Writer 中的消息“文件 zip:///home/timespk/public_html/htmlParser/index.xlsx#xl/media/b1b39dadf76812b4c58e06ea6ddf57841.png 不存在”未捕获的异常“PHPExcel_Writer_Exception” /Excel2007/ContentTypes.php:216 堆栈跟踪:#0 /home/timespk/public_html/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php(164): PHPExcel_Writer_Excel2007_ContentTypes->_getImageMimeType('zip:///home/tim. ..')

1 /home/timespk/public_html/Classes/PHPExcel/Writer/Excel2007.php(224):

PHPExcel_Writer_Excel2007_ContentTypes->writeContentTypes(Object(PHPExcel), false) #2 /home/timespk/public_html/htmlParser/index.php(216): PHPExcel_Writer_Excel2007->save('/home/timespk/p...') #3 { main} 在第 216 行抛出 /home/timespk/public_html/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php

谁能告诉我在这里做错了什么?

4

2 回答 2

1

这是我用来将图像保存到 Excel 文件的代码

$objPHPExcel2->getActiveSheet()->getColumnDimension('A')->setWidth(22);
$image = file_get_contents($imgSrc);
file_put_contents('image' . $highestRow . '.jpg', $image);
$gdImage = imagecreatefromjpeg('image' . $highestRow . '.jpg');
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setImageResource($gdImage);
$objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(150);
$objDrawing->setCoordinates('A'. $highestRow);
$objDrawing->setWorksheet($objPHPExcel2->getActiveSheet());
于 2013-06-14T10:18:58.987 回答
0

我相信我已经找到了适用于此问题的适当解决方案PHPExcel_Worksheet_Drawinghttps ://stackoverflow.com/a/23951597/925196

于 2014-05-30T09:57:18.040 回答