1

good morning,

i have a problem with php pear, which generates excel sheets. this is my php code:

<?PHP
include_once "/Writer.php";

    $xls =& new Spreadsheet_Excel_Writer();
    $xls -> setVersion(8); 


    $format_titel =& $xls->addFormat();
    $format_titel->setBold();
    $format_titel->setAlign('left');
    $format_titel->setSize('14');
    $format_titel->setFgColor('grey');
    $format_titel->setBorder(2);
    $sheet =& $xls->addWorksheet("Tab_1");


    for ($A=0; $A<=59; $A++) {
        $Zeile++;
        $s=0;   

        for ($B=0; $B<=1; $B++){
            $Text_Daten_Excel =  $Daten_Excel[$A][$B]; //$s++;
            $sheet -> write(($A+3), ($B), "TEST TEXT", $format_titel);
        }
    }

    $xls -> send("Sheet.xlsx");  
    $xls->close();
    $xls->sendFile();  
?>

This code works fine. A Excel sheet will generate.

But if I change the line number to more than 59

for ($A=0; $A<=59; $A++) {

the excel sheet will generate but i cant open it. I get this message:

The file is damaged and can not be opened.
8
  • Out of curiosity... $xls =& new? What PHP version are you using? Commented Jul 28, 2016 at 6:53
  • Spreadsheet_Excel_Writer is a rather old library that can only generate Excel 5.0 and Excel 97-2003 binary formats, not current XML-based one. setVersion(8) stands for 97-2003. Whatever software you use to open the file, it may get confused if you call the file Sheet.xlsx. Commented Jul 28, 2016 at 6:57
  • i remove the & in $xls =& new = same Problem. if i call it Sheet.xls = same Problem. PHP Version 5.6.8 Commented Jul 28, 2016 at 7:04
  • Make sure you are using the latest versions of everything (pear/spreadsheet_excel_writer, pear/OLE, etc.) from their GitHub repositories. I've found endless issues in Spreadsheet_Excel_Writer that lead to corrupted files and were patched in unstable versions. Commented Jul 28, 2016 at 7:48
  • can you show me the correct download link? Commented Jul 28, 2016 at 7:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.