codeigniter - Adding a logo to an excel sheet using php excel -
i trying add logo image on generated excel worksheet using code listing below reason nothing
$objreader = phpexcel_iofactory::createreader('excel2007'); $objphpexcel = $objreader->load("workbooks/" . $labref . "/" . $labref . ".xlsx"); $objphpexcel->getactivesheet(2); $objworksheet = $objphpexcel->createsheet(); $objworksheet->settitle("sample summary"); $dir1 = "exclusive_image"; $objdrawing = new phpexcel_worksheet_drawing(); $objdrawing->setname("name"); $objdrawing->setdescription("description"); $objdrawing->setpath(base_url().'exclusive_image/nqcl.png'); $objdrawing->setcoordinates('a1'); $objdrawing->setworksheet($objworksheet->getactivesheet(2)); $objwriter = new phpexcel_writer_excel2007($objphpexcel); $objwriter->save("workbooks/" . $labref . "/" . $labref . ".xlsx");
adding logo simple, try below code.
$objphpexcel = new phpexcel(); $sheet = $objphpexcel->setsheetindexandtitle(1, "your_sheet_title"); // first sheet $objdrawing = new phpexcel_worksheet_drawing(); $objdrawing->setname('logo'); $objdrawing->setdescription('logo'); $logo = base_path() . '/images/logo.png'; // provide path logo file $objdrawing->setpath($logo); $objdrawing->setoffsetx(8); // setoffsetx works $objdrawing->setoffsety(300); //setoffsety has no effect $objdrawing->setcoordinates('b1'); $objdrawing->setheight(75); // logo height $objdrawing->setworksheet($sheet);
Comments
Post a Comment