php - PhpExcel creates multiple worksheets -


hello trying create excel template using phpexcel

for reason image creates new worksheet instead of using current one. when open excel file i've created there worksheet , worksheet1 instead of single one.

    objphpexcel = new phpexcel();             $objworksheet = $objphpexcel->createsheet();                           // set active excel worksheet sheet 0              $objphpexcel->setactivesheetindex(0);                //taslak verileri             $objphpexcel->getactivesheet()->setcellvalue('d'.'1', 'firm');              $objphpexcel->getactivesheet()->setcellvalue('j'.'1', 'sfuformu - fr.ps.21');              $objphpexcel->getactivesheet()->setcellvalue('j'.'3', 'no:');              $objphpexcel->getactivesheet()->setcellvalue('d'.'2', 'name surname signature');              $objphpexcel->getactivesheet()->setcellvalue('a'.'4', 'date');             $objphpexcel->getactivesheet()->setcellvalue('a'.'5', 'stock no:');              $objphpexcel->getactivesheet()->setcellvalue('c'.'5', 'image');              $objphpexcel->getactivesheet()->setcellvalue('e'.'5', 'image');              $objphpexcel->getactivesheet()->setcellvalue('g'.'5', 'resim');              $objphpexcel->getactivesheet()->setcellvalue('i'.'5', 'image');              $objphpexcel->getactivesheet()->setcellvalue('k'.'5', 'quantity');              $objphpexcel->getactivesheet()->setcellvalue('m'.'5', 'price');                 $objdrawing = new phpexcel_worksheet_drawing();                   $objdrawing->setworksheet($objworksheet);                   $objdrawing->setname("name");                   $objdrawing->setdescription("description");                   $objdrawing->setpath('temp/3.jpeg');                   $objdrawing->setcoordinates('f9');                   $objdrawing->setoffsetx(1);                   $objdrawing->setoffsety(5);             $objwriter = new phpexcel_writer_excel2007($objphpexcel);              $objwriter->save('some_excel_file.xlsx');  

enter image description here

enter image description here

you create phpexcel object has en empty sheet index 0.

then create new sheet index 1.

then write stuff sheet index 0 , add picture on second sheet (newly created).

this should solve problem:

$objphpexcel->setactivesheetindex(1);  

note, still create new sheet, first 1 exists. if want use existing worksheet, following:

remove:

   $objworksheet = $objphpexcel->createsheet();                $objphpexcel->setactivesheetindex(0);  

and stuff existing sheet.

$sheet = $objphpexcel->getsheet(0); $sheet->setcellvalue('d'.'1', 'firm')//etc stuff. 

give drawing same sheet:

$objdrawing->setworksheet($sheet); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -