Skip to content

Commit

Permalink
Merge pull request #12 from viest/master
Browse files Browse the repository at this point in the history
fix:result error resourceToArray method
  • Loading branch information
motecshine authored Nov 13, 2017
2 parents 46cf8e6 + 12250fd commit 22b6813
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Writer/ExcelWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ public function resourceToArray()
try {
$reader = IOFactory::load($this->data);
$worksheet = $reader->getActiveSheet()->toArray();
array_shift($worksheet);
$tableHeader = array_shift($worksheet);
$retval = [];
if (isset($this->config['table_header'])) {
foreach ($worksheet as $dataKey => $data) {
foreach ($data as $itemKey => $item) {
$retval[$dataKey][$this->config['table_header'][$itemKey]] = $item;
if(in_array($tableHeader[$itemKey], $this->config['table_header'])) {
$retval[$dataKey][$tableHeader[$itemKey]] = $item;
}
}
}
} else {
Expand Down

0 comments on commit 22b6813

Please sign in to comment.