加载一个单元格时出现错误,但页面未加载我在localhost中工作,但显示: 此页面未找到
这是我的代码:
我的模型Documento.php:
<?php
class Documento extends AppModel {
public $useTable = 'documento';
}
?>
我的控制器DocumentosController.php:
<?php
class DocumentosController extends AppController {
public $helpers = array('Html', 'Form','PhpExcel.PhpExcel');
public $components = array('PhpExcel');
public function index() {
$this->set('documentos', $this->Documento->find('all'));
}
}
?>
我的观点index.ctp:
<?php
App::import('Vendor', 'PHPExcel/Classes/PHPExcel');
App::import('Vendor', 'PHPExcel/Classes/PHPExcel/Reader/Excel2007');
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("autor");
$objPHPExcel->getProperties()->setLastModifiedBy("autor");
$objPHPExcel->getProperties()->setTitle("titulo del Excel");
$objPHPExcel->getProperties()->setSubject("Asunto");
$objPHPExcel->getProperties()->setDescription("Descripcion");
$objPHPExcel->setActiveSheetIndex(0);
// define table cells
foreach($documentos as $documento){
$objPHPExcel->getActiveSheet()->SetCellValue ('A2'.$i,'id');
}
$objPHPExcel->getActiveSheet()->setTitle('Reporte');
$objPHPExcel->getSecurity()->setLockWindows(true);
$objPHPExcel->getSecurity()->setLockStructure(true);
// close table and output
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="documento.xlsx"');
header('Cache-Control: max-age=0');
//Creamos el Archivo .xlsx
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
?>