PhpExcelReader cannot be used to import large amounts of data. Solution

Source: Internet
Author: User
I used phpExcelReader to import a large amount of data. I found an example on the internet. I can use phpexcel to import an excel file to a database. However, once there are more than 122 pieces of data, for example, if an excel file contains 123 pieces of data, it cannot be imported. I will post out the code. let's see: require_once & nbsp;... phpExcelReaderExcelreader. php; $ data & nbsp; phpExcelReader cannot import a large amount of data.
I have found an example on the internet. I can use phpexcel to import an excel file to a database, but once there are more than 122 pieces of data, for example, one excel file contains 123 pieces of data and cannot be imported. I will post the code. let's take a look:
Require_once '../phpExcelReader/Excel/reader. php ';
$ Data = new Spreadsheet_Excel_Reader ();
$ Data-> setOutputEncoding ('gb2312 ');
$ Data-> read ('../lfx.xls ');
}

For ($ I = 1; $ I <= $ data-> sheets [0] ['numrows ']; $ I ++)
{

For ($ j = 1; $ j <= $ data-> sheets [0] ['numcols']; $ j ++)
{

Echo $ data-> sheets [0] ['cells '] [$ I] [$ j];
}
}

When the above code is smaller than 123 excel files, all records can be printed on the web page, but if the number is greater than or equal to 123, it is blank, and I need to import more than 5000 pieces of data, in distress.


Attached phpExcelReader and my excel
Thank you!
------ Solution ----------------------
/*
* PHPExcel. V1.7.6 [read example]
*/
Include 'phpexcel/IOFactory. php ';
$ Filename = "d:/test.xls ";
$ ReadType = PHPExcel_IOFactory: identify ($ filename); // get it if you do not know the document type
$ ExcelReader = PHPExcel_IOFactory: createReader ($ readType );
$ PHPExcelObj = $ excelReader-> load ($ filename );
$ CurrentSheet = $ PHPExcelObj-> getSheet (0); // select the first form (Sheet1) as the current operation form.
$ ExcelRows = $ currentSheet-> getHighestRow (); // get the largest row
$ ExcelColumn = $ currentSheet-> getHighestColumn (); // get the maximum column
Foreach (range (1, $ excelRows) as $ row ){
$ Line ='

';
Foreach (range ('A', $ excelColumn) as $ column ){
$ Line. = $ currentSheet-> getCell ($ column. $ row)-> getValue ().",";
}
$ Line. ='

';
Echo $ line;
}



------ Solution ----------------------
Reference:
I have found an example on the internet. I can use phpexcel to import an excel file to a database, but once there are more than 122 pieces of data, for example, one excel file contains 123 pieces of data and cannot be imported. I will post the code. let's take a look:
Require_once '../phpExcelReader/Excel/reader. php ';
$ Data = new Spreadsheet_Excel_Reader ();
$ Data-> setOutput ......


Use this: http://www.phpclasses.org/package/6235-PHP-Parse-and-access-binary-Excel-files-in-pure-PHP.html

After using it, I think it is very good. it supports Chinese characters and xlsx format. it can traverse and parse all tables, columns, rows, and cells. PhpExcelReader was also used before, and found many problems, so I found this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.