Note that there are some explanatory texts on larger screens.

plurals
  1. POPHPEXCEL to store entries in an array and display
    primarykey
    data
    text
    <p>Here is the extract of my code that display the excel entries and stores into array .</p> <p>The logic is first, detect which entry is invalid , mark it down, then for other valid entry, check whether it is duplicate, if it is, mark it down.</p> <p>Eventually , scan through the whole sheet again, retrieve all the entries that is not in that two list. (duplicate or invalid)</p> <p>The problems of it are:</p> <p>1) When i display the table, although it can display but it warns me that " datatables warning:Request unknown parameter '0' from the data source for row 0"</p> <p>2) When i store into array, it can only store for the first line of row</p> <p>So , i would like to know are there any mistake in my looping logic? and had i used the PHPEXCEL to read spreadsheet in a correct way? Thank you. <pre><code>$reader = PHPExcel_IOFactory::createReader($readerType); $PHPExcel = $reader-&gt;load($file); $sheet = $PHPExcel-&gt;getSheet(0); $highestRow = $sheet-&gt;getHighestRow(); $highestColumn = PHPExcel_Cell::columnIndexFromString($sheet-&gt;getHighestColumn()); $pattern="/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/"; for ($row = 1; $row &lt;= $highestRow; $row++){ for ($head = 0; $head &lt; $highestColumn; $head++){ $testMail = $sheet-&gt;getCellByColumnAndRow($head, $row)-&gt;getValue(); if (preg_match($pattern,$testMail)) $mailColumn=$head; }} if(!isset($mailColumn)) {die('No email column detected, please check your file and import again.');} $invaild[] = NULL ; $email[] = NULL ; $duplicate[] = NULL ; for ($row = 1; $row &lt;= $highestRow; $row++) { for ($y = 0; $y &lt; $highestColumn; $y++) { $val = $sheet-&gt;getCellByColumnAndRow($y, $row)-&gt;getValue(); if ($y == $mailColumn &amp;&amp; !preg_match($pattern,$val)) {$invaild[]=$row;} elseif ($y == $mailColumn &amp;&amp; in_array($val,$email)) {$duplicate[]=$val; $duplicate[]=$row;} //elseif (!in_array($row,$duplicate) &amp;&amp; !in_array($row,$invaild) ) //{echo $val;} if ($y == $mailColumn) {$email[]=$val; $email=array_unique($email);} } } $invaild=array_unique($invaild); foreach ($invaild as $c) {echo $c;} echo "&lt;br&gt;"; foreach ($duplicate as $d) {echo $d;} ?&gt; &lt;div id="stylized" class="view"&gt; &lt;h1&gt;&lt;?echo $file.' Result';?&gt;&lt;/h1&gt; &lt;p&gt;Import from spreadsheet files&lt;/p&gt; &lt;div id="container"&gt; &lt;table cellpadding="0" cellspacing="0" border="0" class="display" id="viewImport"&gt; &lt;thead&gt; &lt;tr&gt; &lt;? for ($head = 0; $head &lt; $highestColumn; $head++){ if ($head==$mailColumn) echo "&lt;th field='col'$head&gt; Email address &lt;/th&gt;"; else echo "&lt;th field='col'$head&gt; Unname coloum $head &lt;/th&gt;"; } ?&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;? for ($row = 1; $row &lt;= $highestRow; $row++) { echo "&lt;tr&gt;"; for ($y = 0; $y &lt; $highestColumn; $y++) { if (!in_array($row,$duplicate) &amp;&amp; !in_array($row,$invaild)){ $val = $sheet-&gt;getCellByColumnAndRow($y, $row)-&gt;getValue(); echo "&lt;td&gt;"; if (!$val) echo "-"; else echo $val; echo "&lt;/td&gt;";} } echo "&lt;/tr&gt;"; } ?&gt; &lt;/table&gt; &lt;/div&gt; I work on this these day but still get this display error thank you ![enter image description here][1] </code></pre> <p><img src="https://i.stack.imgur.com/AkwBa.jpg" alt="enter image description here"></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.
 

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