如何在phpexcel中循环编号?
我使用codeigniter。
$rs = $this->db->get('inventory_barang');
$exceldata="";
foreach ($rs->result_array() as $row){
$exceldata[] = $row;
}
//How should i do for looping
$this->excel->getActiveSheet()->fromArray('I want number to be looping for column A from A4', null, 'A4');
// read data to active sheet
$this->excel->getActiveSheet()->fromArray($exceldata, null, 'B4');
答案 0 :(得分:1)
您可以为数组添加数字:
$rs = $this->db->get('inventory_barang');
$exceldata = [];
foreach ($rs->result_array() as $key=>$row){
$exceldata[] = array_merge([$key], $row);
}
$this->excel->getActiveSheet()->fromArray($exceldata, null, 'A4');