PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

[Bug] Insert footer and header according to documentation

Open scagroup opened this issue 2 years ago • 2 comments

This is:

- [ ] a bug report

What is the expected behavior?

Insert footer and header according to documentation.

What is the current behavior?

There is no footer or header in the document.

What are the steps to reproduce?

        $r1 = IOFactory::load('/app/' . 'tmp'. '/' . 'singAnPropasal.xlsx');
        $r1 ->getActiveSheet()
            ->getHeaderFooter()
            ->setFirstFooter("&C myFooter")
            ->setOddFooter("&C myFooter")
            ->setFirstHeader("&C myFooter")
            ->setEvenHeader("&C myFooter")
            ->setOddHeader("&C myFooter")
            ->setEvenFooter("&C myFooter")
        ;
        $w1 = IOFactory::createWriter($r1, 'Mpdf');
        dd($w1->generateHtmlFooter());

        header('Content-Type: application/pdf');
        header('Content-Disposition: inline; filename="mpdf.pdf"');

        return $w1->save('php://output');

dd return

image

Save result in pdf -> no footer

Which versions of PhpSpreadsheet and PHP are affected?

Checked on both 1.25 and 1.24

scagroup avatar Nov 09 '22 17:11 scagroup

Header/Footer are only options when saving in Excel formats, not for other formats. This is not a bug.

If you feel like going ahead and implementing this feature, we do accept PRs; although parsing the header/footer for the HTML could be quite complicated

MarkBaker avatar Nov 09 '22 19:11 MarkBaker

There is a complicated way to get at least some of the functionality you want. See issue #2236.

oleibman avatar Nov 09 '22 21:11 oleibman