あなたは返事をそんなにこの
$this->load->library('excel');
$filename = 'tab';
$title = 'title name';
$file = $filename . '-' . $name . '.xls'; //save our workbook as this file name
$query = $his->model->function($params);
header('Content-Type: application/vnd.ms-excel'); //mime type
header('Content-Disposition: attachment;filename="'.$file.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle($filename);
$this->excel->getActiveSheet()->setCellValue('A1', $title);
$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20);
$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$this->excel->getActiveSheet()->mergeCells('A1:' . $cell . '1');
$this->excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->setCellValue('A2', 'Subtitulo 1');
$this->excel->getActiveSheet()->setCellValue('B2', 'Subtitulo 2');
$this->excel->getActiveSheet()->setCellValue('C2', 'Subtitulo 3');
$this->excel->getActiveSheet()->setCellValue('D2', 'Subtitulo 4');
$this->excel->getActiveSheet()->setCellValue('E2', 'Subtitulo 5');
$this->excel->getActiveSheet()->getStyle('A2:E2')->getFont()->getColor()->setRGB('555555');
$this->excel->getActiveSheet()->getStyle('A2:E2')->getFont()->setSize(10);
$this->excel->getActiveSheet()->getStyle('A2:E2')->getFont()->setBold(true);
$i = 3;
foreach($query as $item){
$this->excel->getActiveSheet()->setCellValue('A'.$i, $item['cell1']);
$this->excel->getActiveSheet()->setCellValue('B'.$i, $item['cell2']);
$this->excel->getActiveSheet()->setCellValue('C'.$i, $item['cell3']);
$this->excel->getActiveSheet()->setCellValue('D'.$i, number_format($item['cell4'], 0, ',', '.'));
$this->excel->getActiveSheet()->setCellValue('E'.$i, date('d M Y h:i a', strtotime($item['date1'])));
//$this->excel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
$this->excel->getActiveSheet()->getColumnDimension('A')->setAutoSize(TRUE);
$this->excel->getActiveSheet()->getColumnDimension('B')->setAutoSize(TRUE);
$this->excel->getActiveSheet()->getColumnDimension('C')->setAutoSize(TRUE);
$this->excel->getActiveSheet()->getColumnDimension('D')->setAutoSize(TRUE);
$i++;
}
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
ありがとうを試し、DBからの情報にExcelファイルをcreataしたいuが私を助けることができる統合し、あなたはそのは、サーバーエラーとしてダウンロードし、その表示されていない@elddenmedio申し訳@elddenmedio – ohmygood
をお知らせします私のコードで何が間違っている – ohmygood
は何ですrエラー? – elddenmedio