php - Unable to find phpexcel comment in xlsx file -


using code able create comment in excel file.

 $comment = $data_sheet->getcommentbycolumnandrow($col, 1);  $comment->setauthor($table_name . '.' . $field_name);  $comment->setwidth('200px');  $comment->setheight('24px');  $comment->setvisible(false); # activecell.comment.visible = true   $objcommentrichtext = $comment->gettext()->createtextrun($table_name . '.' . $field_name); 

when saved file has comments in it, , can edited on re-opening file comment object in default condition.

$comment = $data_sheet->getcomment('a1'); 

result :-

$comment = phpexcel_comment object (     [_author:private] => author      [_text:private] => phpexcel_richtext object ( [_richtextelements:private] => array ( ) )      [_width:private] => 96pt      [_marginleft:private] => 59.25pt      [_margintop:private] => 1.5pt      [_visible:private] =>      [_height:private] => 55.5pt      [_fillcolor:private] => phpexcel_style_color object (         [_argb:private] => ffffffe1          [_issupervisor:private] =>          [_parent:private] =>          [_parentpropertyname:private] =>      )   ) 

++edit:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">   <authors><author>products.products_id</author><author>products.part_code</author><author>products.products_name</author><author>products.products_quantity</author><author>products.products_status</author><author>products.cost</author><author>products.cost_modifier</author><author>products.delivery_cost</author><author>products.shipping_strategy</author><author>products.products_weight</author><author>products.shipping_amount</author><author>products.products_price</author><author>products.rrp</author><author>products.trade</author><author>products_feed.amazon_price</author><author>products_feed.ebay_price</author></authors>   <commentlist>   <comment ref="a1" authorid="0"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.products_id</t></r></text></comment>   <comment ref="b1" authorid="1"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.part_code</t></r></text></comment>   <comment ref="c1" authorid="2"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.products_name</t></r></text></comment>   <comment ref="d1" authorid="3"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.products_quantity</t></r></text></comment>   <comment ref="e1" authorid="4"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.products_status</t></r></text></comment>   <comment ref="f1" authorid="5"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.cost</t></r></text></comment>   <comment ref="g1" authorid="6"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.cost_modifier</t></r></text></comment>   <comment ref="h1" authorid="7"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.delivery_cost</t></r></text></comment>   <comment ref="i1" authorid="8"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.shipping_strategy</t></r></text></comment>   <comment ref="j1" authorid="9"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.products_weight</t></r></text></comment>   <comment ref="k1" authorid="10"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.shipping_amount</t></r></text></comment>   <comment ref="l1" authorid="11"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.products_price</t></r></text></comment>   <comment ref="m1" authorid="12"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.rrp</t></r></text></comment>   <comment ref="n1" authorid="13"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products.trade</t></r></text></comment>   <comment ref="o1" authorid="14"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products_feed.amazon_price</t></r></text></comment>   <comment ref="p1" authorid="15"><text><r><rpr><sz val="11"/><color rgb="ff000000"/><rfont val="calibri"/></rpr><t>products_feed.ebay_price</t></r></text></comment>   </commentlist> </comments> 

so comment exists in .xlsx file.

none of these has picked comments, yet.

$comment = $data_sheet->getcommentbycolumnandrow($col, 1); $comment = $data_sheet->getcomment('a'. $row); $comments = $data_sheet->getcomments(); 

--edit question, comments correctly loaded in 'excel2007' format ?

here's code snippet used extract comments cells using phpexcel

    $objphpexcel = phpexcel_iofactory::load("myexcelfile.xlsx");      $objworksheet = $objphpexcel->getactivesheet();      // loop through each row in excel file     foreach ($objworksheet->getrowiterator() $row) {      $celliterator = $row->getcelliterator();     $celliterator->setiterateonlyexistingcells(true);      // loop through each column in row     foreach ($celliterator $cell) {          // value of cell         $value = $cell->getvalue();          // comment in cell (if comment exists)         $comment = $objworksheet->getcomment($cell->getcoordinate())->gettext();      }       } 

here link phpexcel comments documentation


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -