Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Delete/Remove Graphs(charts), Pictures(Images) from excel file loaded into PHPExcel?
    primarykey
    data
    text
    <p>I am using PHPExcel class and i am loading template speadsheets and then modifying data and so forth.</p> <p>Depending on what i pass my script dynamically, certain images in the template should be remove and certain graphs(charts) should be removed.</p> <p>I have used the <code>getChartCollection()</code> and the <code>getDrawingCollection()</code> to get everything but i havent figured out a way to modify the collections so that i can remove charts, and/or images from a loaded template.</p> <p>Thanks for any help. Jason K.</p> <p>UPDATE - Thanks to info from Mark Baker below. I wrote the following code that needs to be added to worksheet class until 1.7.9 is released. My code is below.</p> <pre><code>/** * Remove drawing from collection * * @return PHPExcel_Worksheet_BaseDrawing[] */ public function removeImageByIDs($IDs) { if(!is_array($IDs)) $IDs = array($IDs); $drawing_collection = $this-&gt;_drawingCollection; $drawing_collection_copy = $drawing_collection-&gt;getArrayCopy(); foreach($IDs as $ID){ unset($drawing_collection_copy[$ID]); } $drawing_collection_copy = array_values($drawing_collection_copy); $drawing_collection-&gt;exchangeArray($drawing_collection_copy); $this-&gt;_drawingCollection = $drawing_collection; unset($drawing_collection_copy); unset($drawing_collection); return $this-&gt;_drawingCollection; } /** * Remove chart from collection * * @return PHPExcel_Worksheet_BaseDrawing[] */ public function removeChartByIDs($IDs) { if(!is_array($IDs)) $IDs = array($IDs); $chart_collection = $this-&gt;_chartCollection; $chart_collection_copy = $chart_collection-&gt;getArrayCopy(); foreach($IDs as $ID){ unset($chart_collection_copy[$ID]); } $chart_collection_copy = array_values($chart_collection_copy); $chart_collection-&gt;exchangeArray($chart_collection_copy); $this-&gt;_chartCollection = $chart_collection; unset($chart_collection_copy); unset($chart_collection); return $this-&gt;_chartCollection; } </code></pre> <p>Enjoy. Jason K.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload