Wrong excel format issue

Topics: Developer Forum
Jan 5 at 4:11 PM
Edited Jan 5 at 4:23 PM
Hi all,
i'm creating a simple excel file to be submited to a third system to be loaded.

The file by PHPExcel api seems to be good but it can't be loaded by the loading procedure.
If i open the file with excel and save it without doing any change, the file becomes good and the load succeeds.

I notice that file size change from 4kb to 21kb. Why? What do i miss in my file?

Here some details about the files

This is an extract of my code:
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Add some data
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', 'Codice')
            ->setCellValue('B1', 'Quantita');

$sql = "select ... ";
$res = mysql_query( $sql ); 
if ( mysql_num_rows($res) > 0 ) 
{   
    $i=2;
    while ( $rs = mysql_fetch_array($res) )
    {
        $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue('A'.$i, $rs["p_code"] )
                ->setCellValue('B'.$i, str_replace( ".", ",", $rs["qty"] ) );
        $i++;
    }
}

// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);

// filename for download
$filename = "ordine_".$dt."_".$iCount.".xls";

// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=\"$filename\"");
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');

// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
Thanks for help!
Jan 7 at 10:22 AM
anyone?

tks
S