PHP Excel Macro

1,871 views
Skip to first unread message

Brendan Brink

unread,
Feb 2, 2012, 3:39:58 PM2/2/12
to NZ PHP Users Group
Good morning,

I am working on a project that requires the following:

1. Open existing .xls Excel spreadsheet (which contains macros)
2. Modify some basic cell data.
3. Save / export the new file while containing the original macros.

The macros are NOT modified, they just need to be maintained when
creating a new file.

I have googled this and tried PHPExcel library, and have managed to
open the file, modify with basic cell data, and then export, however
the macros are lost.

Wonder if anyone has found a solution out there (paid / free) that can
help me.

Much Appreciated
Brendan.

Jochen Daum

unread,
Feb 7, 2012, 5:44:34 PM2/7/12
to nzp...@googlegroups.com
Hi Brendan,




On 3 February 2012 09:39, Brendan Brink <sell2c...@gmail.com> wrote:
Good morning,

I am working on a project that requires the following:

1. Open existing .xls Excel spreadsheet (which contains macros)
2. Modify some basic cell data.
3. Save / export the new file while containing the original macros.

The macros are NOT modified, they just need to be maintained when
creating a new file.

PHPExcel is an awesome package, but it doesn't look like Macros will be supported: http://phpexcel.codeplex.com/discussions/52723

That post is quite old, but this one supports the same message http://stackoverflow.com/questions/5913818/phpexcel-clone-xlsm-with-macros

Looks like you may have to use COM objects.


Kind Regards,

Jochen Daum

"There is no shortcut to anywhere worth going" - Beverly Sills

Automatem Ltd
Phone: 09 630 3425
Mobile: 021 567 853
Email: j...@automatem.co.nz
Website: www.automatem.co.nz
Skype: jochendaum
http://nz.linkedin.com/in/automatem
http://twitter.com/automatem

Todd Martin

unread,
Feb 9, 2012, 6:05:22 PM2/9/12
to nzp...@googlegroups.com
Hi Brendan

I assume you're running your script on a Windows machine?
Have you considered connecting to the spreadsheet(s) via an ADO database driver and simply editing the data via recordsets?

Todd.
--
Passion is no substitute for reason
Reply all
Reply to author
Forward
0 new messages