Created
June 22, 2016 11:41
-
-
Save amin3d/98f476129438e2d242aae4c1aa4cb345 to your computer and use it in GitHub Desktop.
add to database PHPEXCEL AND CODEIGNITER
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function index() | |
{ | |
$this->load->library('excel'); | |
$objReader = PHPExcel_IOFactory::createReader('Excel2007'); | |
$objReader->setReadDataOnly(true); | |
$objPHPExcel = $objReader->load("uploads/foghetakhasos.xlsx"); | |
$objWorksheet = $objPHPExcel->getActiveSheet(); | |
$highestRow = $objWorksheet->getHighestRow(); | |
$highestColumn = $objWorksheet->getHighestColumn(); | |
$this->load->database(); | |
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); | |
for ($row = 1; $row <= $highestRow; ++$row) { | |
if($objWorksheet->getCellByColumnAndRow(0, $row)->getValue()!='') | |
{ | |
$value = trim($objWorksheet->getCellByColumnAndRow(0, $row)->getValue(),chr(0xC2).chr(0xA0)); | |
$data = array( | |
'title' => $value, | |
'type' => 'foghtakhasos', | |
); | |
$this->db->insert('expertslist', $data); | |
echo 'inserted'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment