<?php
include ('PHPExcel.php');
include ('PHPExcel/IOFactory.php');
include ('PHPExcel\Writer\Excel2007.php');
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$worksheet = $objPHPExcel->getActiveSheet();
$worksheet->setCellValue('A1', 'User name');
$worksheet->setCellValue('B1', 'First name');
$worksheet->setCellValue('C1', 'Last name');
$excelRow = 2;
$worksheet->setCellValue('A' . $excelRow, 'admin');
$worksheet->setCellValue('B' . $excelRow, 'testuser');
$worksheet->setCellValue('C' . $excelRow, 'testuser');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename=Test.xls');
header('Cache-Control: max-age=0');
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('php://output');
exit;
?>
Hi, I would like to export my data as an excel file with php. I can download file as excel. But I take error in excel like below. Can you help me to fix the problem? Thank you in advance.
Fatal error: Uncaught PHPExcel_Writer_Exception: Could not copy temporary zip file C:\Users**\AppData\Local\Temp\php65EC.tmp to php://output. in C:\xampp\htdocs\xampp\PhpTest\PHPExcel\Writer\Excel2007.php:395
Warning copy(C:\Users**\AppData\Local\Temp\php65EC.tmp): failed to open stream: No such file or directory in C:\xampp\htdocs\xampp\PhpTest\PHPExcel\Writer\Excel2007.php
</div>