PHP Excel – modify .xlsm file with macros without loosing macros
Is there any php library or approach to modify xlsm file which has macros without loosing macros. I want to export large data in xlsm template. the xlsm template then export txt file which will be uploaded somewhere
Thanks
2
Answers
If you are using
PhpSpreadsheet for it, you might notice that it sometimes working and sometimes not. The reason is, that .xlsm files are not fully supported.
Usually you create an excel report with macro in VB and afterwards you dont need to change any parameters anymore, but you need to replace the sheet data in the xlsm files without losing VB Macro. If that´s what you are searching for you can go with jsontoxlsm.jar which will be executed from shell.
The Usage is the following as you can see in the Repo:
You can create a JSON file from Python and then execute json2xlsm (keep in mind all Values habe to be in UTF-8):
If you wanna use PHP to create the JSON file and execute json2xlsm, you can do the following: