Welcome Guest, Not a member yet? Register   Sign In
how to update xlsx file data into DB using PHPExcel
#1

(This post was last modified: 06-25-2018, 11:51 PM by kvanaraj.)

I want to update xlsx cell data file into DB using PHPExcel .My cell value starting from Row 12. My Excel sheet printscreen attached. 
My controller file like 
$markid = $this->input->post('markid');
  echo $markid;         
  $asses = $this->input->post('sel_ass1');
  echo $asses;

      $csvMimes = array('application/vnd.ms-excel','text/plain','text/csv','text/tsv');
      if(!empty($_FILES['file']['name']) && in_array($_FILES['file']['type'],$csvMimes))
       {
          if(is_uploaded_file($_FILES['file']['tmp_name']))
            {
              
              //open uploaded csv file with read only mode
              $csvFile = fopen($_FILES['file']['tmp_name'], 'r');   
              // skip first line
              // if your csv file have no heading, just comment the next line
              fgetcsv($csvFile);            
              //parse data from csv file line by line
              while(($line = fgetcsv($csvFile)) !== FALSE)
              {
              //check whether member already exists in database with same email
              $result = $this->db->get_where("pre_marks", array('regno'=>$line[0],"markid"=>$line[1]))->result();
        //echo $result;
        if(count($result) > 0)
        {
         $this->db->update("pre_marks", array("ass1"=>$line[2],"ass2"=>$line[2],"ass3"=>$line[2]),array("regno"=>$line[0]));
        }
          fclose($csvFile);       
         
        $this->session->set_flashdata('success', 'updated successfully');
            redirect(site_url('assessment'));

I want to update each value into the corresponding regno key. kindly help me to solve my problem
. my exported file type is xlsx (2007).

Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
how to update xlsx file data into DB using PHPExcel - by kvanaraj - 06-25-2018, 10:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB