[英]Read and check Excel file
I am new in PHP and ZEND. 我是PHP和ZEND的新手。 I read excel file and check values before insert them to database. 我读取excel文件并在将其插入数据库之前检查值。
for ($row = 2; $row <= $highestRow; ++$row) {//MM
$items = array();
for ($col = 1; $col < $highestColumnIndex; ++$col) {
$cell = $objWorksheet->getCellByColumnAndRow($col, $row);
$items[] = $cell->getValue();
$items[]=trim($items[]);
if ($col = 2) { continue;
}else{
$items[]=preg_replace("/^[-\s]$/", "", $items);// or abs($items[]);
if(!is_numeric ($items)){
$items[]=null;
}
}
}
$rating = mysql_escape_string($items[0]);
and so on...
I get this error: 我收到此错误:
Fatal error: Cannot use [] for reading in C:\Program Files\Apache Software Foundation\httpd-2.2.21\htdocs\project\zend\application\modules\admin\models\bankranking\BankRankAdmin.php on line 204
$items[] = $cell->getValue();
$items[]=trim($items[]);
Try out with this 试试这个
$items[] = trim($cell->getValue());
Remove the following line 删除以下行
$items[]=trim($items[]);
$item = $cell->getValue();
$item = trim($item);
if ($col != 2) {
$item = str_replace(array('-', ' '), "", $item);
if (!is_numeric($item)) {
$item = NULL;
}
}
$items[] = $item;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.