PhpSpreadsheet
PhpSpreadsheet copied to clipboard
Feature req: A TemplateProcessor class.
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?
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}
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.
Same issue here, what a pity I need to loop the array
Anybody is welcome to submit a PR