Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields in header not modified #14

Open
ydakilux opened this issue Dec 4, 2019 · 1 comment
Open

Fields in header not modified #14

ydakilux opened this issue Dec 4, 2019 · 1 comment

Comments

@ydakilux
Copy link

ydakilux commented Dec 4, 2019

I made a small template with your basic template as base and it's working
But if the fields are in the Header of the page in Excel, fields are not updated, while the same fields are updated if they are on the page.
Just to be sure I have put the same fields in the footer and in a normal cell

@ydakilux
Copy link
Author

Hello,

I have found a solution to change the PageHeader and PageFooter using the BEFORE_SAVE event

I just changed the declaration to

      PhpExcelTemplator::BEFORE_SAVE => function(Spreadsheet $spreadsheet, $writer) { .. }

So I just removed the IWriter type, otherwise it generate an exception ( problem between Iwriter and XlsWriter )

For your information information and/or for the example, this is how a change the PageHeader and PageFooter :

    $events = [
      PhpExcelTemplator::BEFORE_SAVE => function(Spreadsheet $spreadsheet, $writer) {
          // fires before saving to a file. It is used when you need to modify the $writer or $spreadsheet object before saving, for example, $writer->setPreCalculateFormulas(false);

          // Headers
          $spreadsheet->getActiveSheet()->getHeaderFooter()->setOddHeader('New PageHeader Text);

          // Footers
          $spreadsheet->getActiveSheet()->getHeaderFooter()->setEvenHeader('New Text PageFooter Text');
      },

    ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant