12-07-2017, 12:47 AM (This post was last modified: 12-12-2017, 07:20 AM by ciadmin.)
hello, programmers.
Would you help me in this problem?
I am using PHPExcel to generate excel files.
Now my query looks like this.
MODEL:
Code:
class ReportModel extends CI_Model
{
public function getReport() {
$this->db->select('a.LnCode as Line Code, c.MachDesc as Machine');
$this->db->from('tbl_Audit_H as a');
$this->db->join('tbl_Audit_D as b', 'a.ChkNum = b.ChkNum');
$this->db->join('tbl_Machines as c', 'a.MachCode = c.MachCode');
$result = $this->db->get();
return $result->result_array();
}
public function getMachine() {
$result = $this->db->get('tbl_Machines');
return $result->result_array();
}
}
CONTROLLER:
Code:
public function getReport() {
$machines = $this->reportmodel->getMachine();
$results = $this->reportmodel->getReport();
$objPHPExcel = new PHPExcel();
/* Cache Results */
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory;
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
foreach ($machines as $machine) {
// Create a new worksheet called “My Data”
$myWorkSheet = new PHPExcel_Worksheet($objPHPExcel, $machine['MachDesc']);
// Attach the “My Data” worksheet as the first worksheet in the PHPExcel object
$objPHPExcel->addSheet($myWorkSheet);
$objPHPExcel->setActiveSheetIndexByName($machine['MachDesc']);
$activeSheet = $machine['MachDesc'];