Excel found unreadable content

Topics: User Forum
Dec 10, 2010 at 5:45 PM
Edited Dec 10, 2010 at 5:46 PM


I have read some other threads and i have uptaded the php_zip.dll to the 5.2.9 . 
Before using this dll i was getting excel found unreadable content and when i clicked yes it said the file was corrupted and i couldnt read the file.

Now after getting the new dll im still getting excel found unreadable content but now excel is able to repair the file and im able to read it.

So now im wondering if I have some error with my codes .


/** Error reporting */

include "05featuredemo.inc.php";

/** PHPExcel_IOFactory */
require_once 'Classes/PHPExcel/IOFactory.php';

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
// Echo memory peak usage
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";


\/ 05featuredemo.inc.php \/


/** Error reporting */

/** PHPExcel */
require_once dirname(__FILE__) . '/Classes/PHPExcel.php';

// Cria Objeto phpexcel
$objPHPExcel = new PHPExcel();

// Propriedades
							 ->setLastModifiedBy("ULtimo a modificar")
							 ->setTitle("Titulo do Documento")
							 ->setSubject("assunto da planilha")
							 ->setDescription("descricao do documento")
							 ->setKeywords("palavras-chave palavra chave")

$row = 3;
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'ID');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'NOME');
$objPHPExcel->getActiveSheet()->setCellValue('C2', 'DESCRICAO');

$objPHPExcel->getActiveSheet()->setCellValue('B23', 'Invoice');
$objPHPExcel->getActiveSheet()->setCellValue('D23', PHPExcel_Shared_Date::PHPToExcel( gmmktime(0,0,0,date('m'),date('d'),date('Y')) ));


can someone say if theres anything wrong with my code please?

thx .

and sry about my bad english (im from brazil )

Dec 10, 2010 at 9:26 PM

When you're using the ?> and <?php tags, is there any output between those tags? spaces? blank lines?

Try opening the resulting file in a text editor and see if there are any error messages visible, or any spaces/newlines as the first few bytes of the file

Dec 13, 2010 at 9:37 AM

well after the <?php and before de ?> i usually break a line but when i opened the excel file on ultraedit the first line was PK.... and then various simbols . 

Dec 13, 2010 at 10:11 AM

i guess pk is an normal thing because i downloaded this file http://cid-04406c21151c87cb.office.live.com/self.aspx/Public%20Folder/test.xlsx and it opens normally without any message and it also starts with pk and a bunch of dots

Dec 13, 2010 at 10:19 AM

well i dont know if its any help but i took off the getpropertie part and now there´s no more error msg , thx for your help MarkBaker

Aug 4, 2011 at 11:50 AM

Probably the problem is with statement:

echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";

It gets mixed with file output. Try openinggenerated file in some ditor and look for "Peak memory usage:".

I had similar problem.
Aug 12, 2011 at 7:39 PM

Hi everybody!

I am having a problem too.

I created my own class to manage basic function of PHPExcel class in order to make easier for people here at my job to export to Excel 5 files. When I use that class in a Windows system everything works perfectly, but we also have some servers running in FreeBSD, and we I try to run the class there the file is automatically downloaded, there are no errors opening the file but data in it is unreadable, but the problems does not happen if I save the data to a file in the server and then download it via FTP. I checked the file with a HEX editor and found out that there are some extra characters at the beginning of the file and that's the reason of the unreadable file. Any idea why that is happening?

Thanks a lot in advance!