SMC EXCEL LIB ADDED
This commit is contained in:
parent
31cd27ce40
commit
53aba4d3fa
79
api/application/helpers/readexceldata_helper.php
Normal file
79
api/application/helpers/readexceldata_helper.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
class readexceldata
|
||||
{
|
||||
|
||||
public static function getExcelSectionData($file_path_withname,$section_id = null)
|
||||
{
|
||||
$CI =&get_instance();
|
||||
$CI->load->library('myspreadsheet');
|
||||
|
||||
|
||||
// $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
|
||||
$spreadsheet_io_fact = $CI->myspreadsheet->getIOFactory($file_path_withname);
|
||||
//$curr_spreadshett = $spreadsheet_io_fact::load($file_path_withname);
|
||||
//echo $spreadsheet_io_fact->getSheetCount();
|
||||
$spreadsheet_io_fact->setActiveSheetIndex(0);
|
||||
$sheetData = $spreadsheet_io_fact->getActiveSheet()->toArray(null, false, false, true);
|
||||
// print_r($sheetData);
|
||||
return SELF::seperateSectionData($section_id,$sheetData);
|
||||
|
||||
// $CI->load->model('PD_Model');
|
||||
//return ( $CI->PD_Model->selectCustomRecords(array('pd_co_applicant_id','applicant_name'),array('fk_pd_id' => $pd_id),PDAPPLICANTSDETAILS));
|
||||
|
||||
// return array('sam'=>'dsnlskdnm');
|
||||
// print_r(array('sam'=>'dsnlskdnm'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
static function seperateSectionData($section_id,$sheetData)
|
||||
{
|
||||
//echo 'worked';die();
|
||||
$CI =&get_instance();
|
||||
$CI->load->model('PD_Model');
|
||||
$section_ref_data = $CI->PD_Model->selectCustomRecords(array('*'),array('isactive' => 1,'section_id' => $section_id),EXCEL_COLUMN_REF_NAME);
|
||||
$return_data = array();
|
||||
if($section_id == null)
|
||||
{
|
||||
unset($sheetData[1]);
|
||||
foreach ($sheetData as $key => $value)
|
||||
{
|
||||
|
||||
// print_r($value['C']);die();
|
||||
$temp['key_name'] = SELF::returnMatchedData($section_ref_data,$value);
|
||||
$temp['value'] = $value['C'];
|
||||
$return_data[] = $temp;
|
||||
if($key == 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ($return_data);
|
||||
|
||||
}
|
||||
|
||||
static function returnMatchedData($arr,$val)
|
||||
{
|
||||
foreach ($arr as $key => $value)
|
||||
{
|
||||
if($val['A'] == $value['ref'])
|
||||
{
|
||||
return $value['key_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getApplicantsNameById($id,$latest_applicants_names,$type = 1) //$type i for return name only, 2 for return title only, and 3 for return both
|
||||
{
|
||||
foreach ($latest_applicants_names as $key => $value) {
|
||||
|
||||
if($id == $value['pd_co_applicant_id'])
|
||||
{
|
||||
return $type == 1 ? $value['applicant_name'] : ($type == 2 ? $value['title'] : ($value['title'].' '.$value['applicant_name']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
29
api/application/libraries/Myspreadsheet.php
Normal file
29
api/application/libraries/Myspreadsheet.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once( APPPATH.'vendor/autoload.php');
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
class myspreadsheet //extends PHPExcel
|
||||
{
|
||||
function getMySpreadSheet()
|
||||
{
|
||||
//echo 'dsds';
|
||||
return new Spreadsheet();
|
||||
}
|
||||
|
||||
function getXlsx($spreadsheet)
|
||||
{
|
||||
//echo 'dsds';
|
||||
return new Xlsx($spreadsheet);
|
||||
}
|
||||
|
||||
function getIOFactory($file)
|
||||
{
|
||||
//echo 'dsds';
|
||||
return IOFactory::load($file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user