PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

Feature req: A TemplateProcessor class.

Open theopensourcerer opened this issue 5 years ago • 4 comments

This is:

- [ ] a feature request

With PHPWord, there is a helper class for Template Processing [1]. This means you can enter things like ${MY_VAR} into a word processing document and rapidly replace these vars with data (and/or images) through code.

I can see this might be useful in a spreadsheet scenario too (CRM-type data for example, report engine exports etc...)

[1] https://github.com/PHPOffice/PHPWord/blob/develop/src/PhpWord/TemplateProcessor.php

Has this been considered or is it on the radar?

theopensourcerer avatar Oct 19 '20 10:10 theopensourcerer

This is exactly my use case, and as of right now I have to loop through all cells in the worksheet and check if they have a placeholder like ${my_placeholder}

Francesco-Manicardi avatar Dec 21 '20 15:12 Francesco-Manicardi

Plus one here. After brief research on TemplateProcessor in PHPWord, it seems that implementation should be very similar. Even official docs (https://phpword.readthedocs.io/en/latest/templates-processing.html) says "You can create an OOXML document template" instead of explicitly specifying Word. XLSX archive seems to contain sharedStrings.xml file where template values could be replaced. It doesn't work on the formulas by simple string replacement but it should be solvable.

acirulis avatar Dec 18 '22 13:12 acirulis

Same issue here, what a pity I need to loop the array

Anubarak avatar Apr 21 '23 06:04 Anubarak

Anybody is welcome to submit a PR

MarkBaker avatar Apr 21 '23 08:04 MarkBaker