i saw this problem in so many posts. but none have been answered. first time when I insert image in an excel file, no problem is there.but if i load that excel file again and try to insert another image in another cell,following problem occurs:
Fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'File zip://C:xampphtdocsWellest.xlsx#xl/media/well1.bmp does not exist' in C:xampphtdocsWellClassesPHPExcelWriterExcel2007ContentTypes.php:242 Stack trace: #0 C:xampphtdocsWellClassesPHPExcelWriterExcel2007ContentTypes.php(181): PHPExcel_Writer_Excel2007_ContentTypes->_getImageMimeType('zip://C:xampp...') #1 C:xampphtdocsWellClassesPHPExcelWriterExcel2007.php(246): PHPExcel_Writer_Excel2007_ContentTypes->writeContentTypes(Object(PHPExcel), false) #2 C:xampphtdocsWellest.php(125): PHPExcel_Writer_Excel2007->save('test.xlsx') #3 {main} thrown in C:xampphtdocsWellClassesPHPExcelWriterExcel2007ContentTypes.php on line 242.
This is my code to draw:
`$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('image');
$objDrawing->setDescription('nnnnn');
$objDrawing->setPath('images/well.bmp');
$objDrawing->setCoordinates('I'.$s);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());`
I searched lot and I saw some posts regarding it. but none of them have been answered.
Edit: My code:
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';
$name='statistics.xlsx';
if(file_exists($name))
{
$objPHPExcel = PHPExcel_IOFactory::load($name);
$lastRow = $objPHPExcel->getActiveSheet()->getHighestRow();
$j=$lastRow+10;
}
else
{
$j=1;
$objPHPExcel = new PHPExcel();
}
$i='A';
$objPHPExcel->setActiveSheetIndex(0);
// I am not writing the entire data
$objPHPExcel->getActiveSheet()->setCellValue($i++.$j, 'name');
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('image');
$objDrawing->setDescription('image');
$objDrawing->setPath('image.png');
$objDrawing->setCoordinates('E'.$s);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save($name);
See Question&Answers more detail:os