2

I develop webapp with PHP5 to read or to actualize xlsm files.

I have tried with PHPEXCEL, but this library not supported xlsm-files format. Everything what I need, is open the file, write the data in there and stores as a xlsm-file. The macro should not be changed.

It is important that the file returns which contains the macros because this file it is used daily to do several import. I may not change the file-format.

if somebody has tips or tutor's courses for this specific task has, please writes to me.

Thanks 4 your help

Janie
  • 21
  • 2
  • Your problem is simiar to [this one](http://stackoverflow.com/questions/5913818/phpexcel-clone-xlsm-with-macros). – fsenart Jun 12 '12 at 14:15

2 Answers2

0

If you need to retain macros from an Excel template, then you'll need to use something like COM because there aren't any other libraries that handle macros from PHP

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • thanks i will try with COM but first install this on the Server. do i need to save the xlsm-file on the Server? – Janie Jun 13 '12 at 07:44
  • The copy of MS Excel on the server is going to be opening the file under the control of your script via COM, so the file needs to be accessible from the server's MS Excel... so yes, on the server or a disk accessible from the server – Mark Baker Jun 13 '12 at 07:49
  • hye Mark do you know how to speed loading xls-file with PHPExcel – Janie Jun 14 '12 at 10:45
  • @Janie - if I did have a nice, simple answer to speed up reading files in PHPExcel, you can be sure it would already be implemented – Mark Baker Jun 14 '12 at 10:46
  • ok my App ist too Slow because i open the xls-file $openFile= new PHPExcel_Reader_Excel5(); $excel = $openFile->load('Formular.xls'); – Janie Jun 14 '12 at 11:12
0

xslm files are actually ZIP files with XML documents and other assets inside them. PHPEXCEL and other similar MS Office file format readers and writers only read the older binary-blob formats, not the newer Office Open XML formats.

Try using ZipArchive to open the file in PHP, and one of the PHP XML libraries to read the xml inside the file. As long as you don't alter the macros, the macros will be preserved.

However, if you actually need to execute the macros, you need a full Office runtime. In this case you must use COM on windows with a copy of Office to run the file.

Francis Avila
  • 31,233
  • 6
  • 58
  • 96
  • PHPExcel reads both BIFF files (BIFF5 to BIFF8) .xls __and__ Office Open XML .xlsx files. It just doesn't do the macros in xlsm – Mark Baker Jun 12 '12 at 14:24
  • thanks i will try with COM but first install this on the Server. do i need to save the xlsm-file on the Server? – Janie Jun 13 '12 at 07:44