projects
/
Pman.Core
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d1453ee
)
ExcelToJson.php
author
Edward
<edward@roojs.com>
Mon, 18 Mar 2013 03:11:27 +0000
(11:11 +0800)
committer
Edward
<edward@roojs.com>
Mon, 18 Mar 2013 03:11:27 +0000
(11:11 +0800)
ExcelToJson.php
patch
|
blob
|
history
diff --git
a/ExcelToJson.php
b/ExcelToJson.php
index
bce3a6e
..
aee5e28
100644
(file)
--- a/
ExcelToJson.php
+++ b/
ExcelToJson.php
@@
-50,15
+50,37
@@
class Pman_Core_ExcelToJson extends Pman_Roo
if(!array_filter($n)){
$header = true;
}
if(!array_filter($n)){
$header = true;
}
+
if(!$header){
$rows[$n[0]] = $n[1];
continue;
}
if(!$header){
$rows[$n[0]] = $n[1];
continue;
}
- foreach($n as $k) {
- $cols[] = strtoupper(trim($k));
+
+ if(!$cols){
+ $cols = array();
+ foreach($n as $k) {
+ $cols[] = strtoupper(trim($k));
+ }
+
+ if (empty($cols)) {
+ continue;
+ }
+ foreach($req as $r) {
+ if (!in_array($r,$cols)) {
+ $cols = false;
+ break;
+ }
+ }
+ continue;
+ }
+
+ foreach($cols as $i=>$k) {
+ $row[$k] = $n[$i];
}
}
+ $rows[] = $row;
+
}
}
- exit;
+
if (empty($cols)) {
$this->jerr("could not find a row with " . implode(' / ', $req));
}
if (empty($cols)) {
$this->jerr("could not find a row with " . implode(' / ', $req));
}