PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.27k stars 3.43k forks source link

[Bug] Insert footer and header according to documentation #3159

Open scagroup opened 1 year ago

scagroup commented 1 year ago

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

MarkBaker commented 1 year ago

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

oleibman commented 1 year ago

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