3
가 여기에 엑셀이 데이터베이스에서 데이터 파일을 생성하는 로컬 호스트에서 잘 작동 내 코드 서버에 파일을 엑셀 생성하지만, 서버 호스팅에 빈 엑셀 파일 생성phpexcel 라이브러리는 로컬 호스트에서 잘 작동하지만 빈은
// Starting the PHPExcel library
$this->load->library('PHPExcel');
//$this->load->library('PHPExcel/IOFactory');
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle("export")->setDescription("none");
$objPHPExcel->setActiveSheetIndex(0);
// Field names in the first row
$fields = $query->list_fields();
$col = 0;
foreach ($fields as $field)
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
$col++;
}
//format the column sizes
$sheet = $objPHPExcel->getActiveSheet();
$cellIterator = $sheet->getRowIterator()->current()->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true);
/** @var PHPExcel_Cell $cell */
foreach($cellIterator as $cell) {
$sheet->getColumnDimension($cell->getColumn())->setAutoSize(true);
}
//var_dump($query->result());
//die;
// Fetching the table data
$row = 2;
foreach($query->result() as $data)
{
$col = 0;
foreach($fields as $field)
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $data->$field);
$col++;
}
$row++;
}
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');
ob_clean();
$objWriter->save('php://output');
을
로컬 서버에 올바른 종속성 (모듈)이 설치되어 있고 호스트 서버에 누락 된 것일 수 있습니다. 그것은 우선 조사해야 할 것입니다. – TimBrownlaw
에도이 문제가있었습니다. 해결책을 찾지 못했습니다 .-- ( –