File Not Found

Topics: Developer Forum, User Forum
May 10, 2011 at 7:23 PM
Edited May 10, 2011 at 7:23 PM

I have a script that looks like this:

 

<?php
date_default_timezone_set('Europe/London');
require_once 'Classes/PHPExcel.php';

// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Set properties
$objPHPExcel->getProperties()->setCreator("Illution")
							 ->setLastModifiedBy("Illution")
							 ->setTitle("Computerinfo Export")
							 ->setSubject("Computerinfo Export")
							 ->setDescription("Computerinfo Export")
							 ->setKeywords("Computer Info Computerinfo Export Illution")
							 ->setCategory("Export");

$Arr = array(array("Type" => "B�rbar","Computermodel" => "HP Ting", "Computernavn" => "Lafh2312412"));
// Add some data
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', 'Type')
			->setCellValue('B1', 'Computermodel')
			->setCellValue('C1', 'Computernavn');
			/*
			->setCellValue('A2', 'B�rbar')
            ->setCellValue('B2', 'HP Ting')
            ->setCellValue('C2', 'Lafh1234354');
			*/
			
	$CharsArr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
foreach ($Arr as $Number => $SubArr)
{
	
	$Charnum = 0;
	
	foreach ($SubArr as $Name => $Value)
	{
		$Cell = $CharsArr[$Charnum];
		$Cell .= $Number+2;
		$objPHPExcel->setActiveSheetIndex(0)->setCellValue($Cell, $Value);	
		$Charnum++;	
	}
				
};
$objPHPExcel->getActiveSheet()->getStyle('A1:C1')->applyFromArray(
	array('fill' 	=> array(
								'type'		=> PHPExcel_Style_Fill::FILL_SOLID,
								'color'		=> array('argb' => '0000FF00')
							),
		 )
	);
	
$objPHPExcel->getActiveSheet(0)->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet(0)->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->getActiveSheet(0)->getColumnDimension('C')->setAutoSize(true);
// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle('Data');


// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
/*
// Save Excel 2007 file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
*/

// Redirect output to a client's web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Export.xlsx"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
?>

When i runs on my linux server the browser just says "File not fould".

I know the file exists, and when i remove the line

"$objWriter->save('php://output');"

is "works", but it doesnt output anything.

I tested it on a Windows machine at it worked fine.

My linux server also has Gzib Compression, has it something with that to do?

May 10, 2011 at 7:31 PM
Edited May 10, 2011 at 7:46 PM

I have the following parameter in the "Configure Command" "--with-zip" is that good enough?

Also i found out that i can make "Excel5" files, but can't make "Excel2007" files.

I have php version "5.2.17"

Coordinator
May 10, 2011 at 8:13 PM

If ZipArchive isn't enabled, then you can enable the built-in PCLZip wrapper using

PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);

before instantiating your Writer.

This currently only works with the Excel2007 Writer, and you should download the latest SVN version of the code.

May 10, 2011 at 8:25 PM

THAAAAAAAAAAAAAAANK YOU!!!!!! You saved my *day* :D :D :D