Home > Backend Development > PHP Tutorial > PHP How to use phpexcel to import database_PHP tutorial

PHP How to use phpexcel to import database_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 14:59:07
Original
914 people have browsed it

Without further ado, let’s go straight to the code

Copy the code The code is as follows:

error_reporting( E_ALL); //Open error
set_time_limit(0); //Script does not timeout

date_default_timezone_set('Europe/London'); //Set time

/**Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . 'http://www.jb51.net/../Classes/');//Set environment variables

/**PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';

//$inputFileType = 'Excel5'; //This is for reading xls
$inputFileType = 'Excel2007';//This is
//$inputFileName = './sampleData/example2.xls';
$inputFileName = './sampleData/book.xlsx';

echo 'Loading file ',pathinfo ($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
';
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
                                                                  Get the total number of rows
$highestColumn = $sheet->getHighestColumn(); //Get the total rows
*/
$objWorksheet = $objPHPExcel->getActiveSheet(); //Get the total rows
        $highestRow = $objWorksheet->getHighestRow();//Get the total number of columns

                                                                   $highestRow =                                                  $highestRow                                                                                            $highestRow =      = $objWorksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);//Total number of columns
echo 'highestColumnIndex='.$highestColumnIndex;
echo "&
$headtitle=array();
for ($row = 1;$row <= $highestRow;$row++)
{
$strs=array();
                                                                                                                                           =$objWorksheet ->getCellByColumnAndRow($col, $row)->getValue();
                                                                                                     🎜> 'word2'=>"$strs[1]",
'word3'=>"$strs[2]",
'word4'=>"$strs[3]",
               ); }
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328157.htmlTechArticle Without further ado, let’s go directly to the code. Copy the code as follows: ?php error_reporting(E_ALL); //Open Error set_time_limit(0); //The script does not timeout date_default_timezone_set('Europe/Lo...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template