I have a sqlite database named: db with table named student, columns: name and email. Similarly I have excel file studentdb.xlsx having the similar column name with thousand of rows. I want to read the excel file and import the data into sqlite database through a php script. How to do that?
Asked
Active
Viewed 985 times
1 Answers
0
For this you have to use a third party library like SimpleExcel
.
Parsing an Excel 2003 XML file, simplified:
<?php
use SimpleExcel\SimpleExcel;
require_once('../your/project/directory/here/lib/SimpleExcel/SimpleExcel.php'); // load the main class file (if you're not using autoloader)
$excel = new SimpleExcel('xml'); // instantiate new object (will automatically construct the parser & writer type as XML)
$excel->parser->loadFile('example.xml'); // load an XML file from server to be parsed
$foo = $excel->parser->getField(); // get complete array of the table
$bar = $excel->parser->getRow(3); // get specific array from the specified row (3rd row)
$baz = $excel->parser->getColumn(4); // get specific array from the specified column (4th row)
$qux = $excel->parser->getCell(2,1); // get specific data from the specified cell (2nd row in 1st column)
echo '<pre>';
print_r($foo); // echo the array
echo '</pre>';
?>

Mayank Pandeyz
- 25,704
- 4
- 40
- 59
-
Can you please elaborate the solution @Mayank Pandeyz – Feb 27 '17 at 12:10
-
Hello all Problem is solved! I used the PHPExcel Library to import the rows from **xlsx** file to **sqlite** database.I took help from here: [link](http://www.discussdesk.com/import-excel-file-data-in-mysql-database-using-PHP.htm) – Feb 28 '17 at 15:15