Click here to Skip to main content
14,970,418 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using phpexcel with codeigniter. I want to insert an image to excel file.and i am using below code

but it gives the error for file. It says file not found. But that file exists in correct folder. And I gave correct path. Please help me.The file exists in assets folder.

What I have tried:

$objDrawing = new PHPExcel_Worksheet_Drawing();
				$logo = base_url() . 'images/logo.png'; // Provide path to your logo file
				$objDrawing->setOffsetX(8);    // setOffsetX works properly
				$objDrawing->setOffsetY(300);  //setOffsetY has no effect
				$objDrawing->setHeight(75); // logo height
Updated 26-Oct-20 18:49pm
Richard MacCutchan 11-Sep-17 2:58am
If the error says 'file not found' then you need to chalk exactly what path is being generated.
Mohibur Rashid 11-Sep-17 23:46pm
Use file_exists function to check if file exists

you should replace base_url() with $_SERVER['DOCUMENT_ROOT']
Simple issue in your code :

$logo = base_url()

and your are using another variable here :

replace $pr_file with $logo

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900