Home > Backend Development > PHP Tutorial > 用phpExcelReader不能导入大量数据,该怎么解决

用phpExcelReader不能导入大量数据,该怎么解决

WBOY
Release: 2016-06-13 13:29:47
Original
937 people have browsed it

用phpExcelReader不能导入大量数据
我在网上找了个例子,可以通过phpexcel将excel文件导入到数据库中,但是数据一旦超过122条,例如一个excel文件中有123条数据就无法导入。我讲代码贴出来,大家看看:
require_once '../phpExcelReader/Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('GB2312');
$data->read('../lfx.xls');
}

for ($i = 1; $i sheets[0]['numRows']; $i++) 
  {

for ($j = 1; $j sheets[0]['numCols']; $j++) 
{

echo $data->sheets[0]['cells'][$i][$j];
}
}

以上代码在excel文件小于123条时就可以打印出所有记录在网页上,但是大于等于123条时就是空白,而我需要导入一个5000条以上的数据,苦恼中。


附上phpExcelReader以及我的excel
感谢各位了!

------解决方案--------------------

PHP code
/*
 * PHPExcel.V1.7.6版本 [读取示例]
 */
include 'PHPExcel/IOFactory.php';
$filename = "d:/test.xls";
$readType = PHPExcel_IOFactory::identify($filename);  //在不知道文档类型的情况下获取
$excelReader = PHPExcel_IOFactory::createReader($readType);
$PHPExcelObj = $excelReader->load($filename);
$currentSheet = $PHPExcelObj->getSheet(0);            //选取第一张表单(Sheet1)为当前操作的表单
$excelRows = $currentSheet->getHighestRow();          //获取最大行
$excelColumn = $currentSheet->getHighestColumn();     //获取最大列
foreach(range(1,$excelRows) as $row){
    $line = '<p>';
    foreach(range('A',$excelColumn) as $column){
        $line .= $currentSheet->getCell($column.$row)->getValue().",";
    }
    $line .= '</p>';
    echo $line;
}
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨
我在网上找了个例子,可以通过phpexcel将excel文件导入到数据库中,但是数据一旦超过122条,例如一个excel文件中有123条数据就无法导入。我讲代码贴出来,大家看看:
require_once '../phpExcelReader/Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutput……
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template