Group_Concat将数据插入单独的单元格

我在这里挣扎了一下,我有一个group_concat ,我希望每个值被分离到一个不同的单元格,以便总单元格获得这些连接值的总和。

 $this->db->select("date, reference_no, biller, customer, GROUP_CONCAT(CONCAT(" . $this->db->dbprefix('sale_items') . ".product_name) SEPARATOR '\n') as iname, GROUP_CONCAT(CONCAT(round( " . $this->db->dbprefix('sale_items') . ".quantity)) SEPARATOR '\n') as cqty, GROUP_CONCAT(TRUNCATE(CONCAT(" . $this->db->dbprefix('sale_items') . ".net_unit_price),2) SEPARATOR '\n') as unitbeforetax,GROUP_CONCAT(ROUND( CONCAT(" . $this->db->dbprefix('sale_items') . ".net_unit_price * " . $this->db->dbprefix('sale_items') . ".quantity ),2) SEPARATOR '\n') as beforetax,GROUP_CONCAT(round(CONCAT(" . $this->db->dbprefix('sale_items') . ".item_tax),2 ) SEPARATOR '\n') as producttax,GROUP_CONCAT(round(CONCAT(" . $this->db->dbprefix('sale_items') . ".unit_price * " . $this->db->dbprefix('sale_items') . ".quantity),2) SEPARATOR '\n') as unitp, grand_total, paid, payment_status", FALSE) 

我将concat调用到phpexcel中,所以语法是:

 $this->excel->getActiveSheet()->SetCellValue('F' . $row, $data_row->unitbeforetax); $this->excel->getActiveSheet()->SetCellValue('G' . $row, $data_row->beforetax); $this->excel->getActiveSheet()->SetCellValue('H' . $row, $data_row->producttax); $this->excel->getActiveSheet()->SetCellValue('I' . $row, $data_row->unitp); 

现在这将返回新行的结果,但Excel和phpexcel将不会以这种格式计算总和:

 1 1 

我需要的是每个值被分离到主单元格下的新单元格或Excel计算值时将接受的任何分隔符…

提前致谢

Interesting Posts