In PHP development, you will definitely encounter the need to import the contents of excel files into the database. php-excel-reader is a class for reading excel. It can be easily used to read excel files. It is very convenient.
php-excel-reader download address: http://www.jb51.net/codes/67223.html
I downloaded the php-excel-reader-2.21 version. I encountered a few minor problems when using it. I will elaborate on it later. Here is a php example:
The excel I use is as shown below:
The php code is as follows:
Let’s talk about this small problem:
(1)Deprecated appears: Function split() is deprecated in. . . Error
Solution: Change split in excel_reader2.php source code to explode. For details, click on the difference between explode and split in php
(2) Deprecated: Assigning the return value of new by reference is deprecated in error
Solution: Remove & from $this->_ole =& new OLERead() in the excel_reader2.php source code, because the =& symbol is abolished in php5.3 and the = reference is used directly
(3) Solution to garbled code problem:
The constructor is function Spreadsheet_Excel_Reader($file='',$store_extended_info=true,$outputEncoding=''). Its default encoding is utf-8. If not specified, garbled characters may occur. You can pass $data ->setOutputEncoding('GBK'); specifies, and if you use the dump() function, the dump() function will output the excel content in html format, use htmlentities to convert the characters into html, it uses ISO8559-1 encoding by default Yes, so you have to change the htmlentities($val) function in the excel_reader2.php source code to htmlentities($val,ENT_COMPAT,"GB2312");.
Finally, php-excel-reader has two important methods for operating excel :
1.dump(), which can output excel content in html format:
echo $data->dump(true,true);
2. Store the excel data in the array, use $data->sheets, print it as follows:
Garbled characters starting with ^quxjg$c
How to open img file
Compare the similarities and differences between two columns of data in excel
You need permission from admin to make changes to this file
excel duplicate item filter color
How to copy an Excel table to make it the same size as the original
Excel table slash divided into two
Excel diagonal header is divided into two