rewrite excel(.xls) then macro lost

Topics: Developer Forum, Project Management Forum, User Forum
Nov 2, 2012 at 4:26 AM


I had a excel(A_Result.xls) file with macro, and i use browser access the php ,

the php file only  load xls and save it with any modify.

and then macro in A_Result.xls is lost

Is there any way to accomplish what I'm trying to do? 


or tell me what is happened?


Thanks very much,



my code:

$objReader =PHPExcel_IOFactory::createReader("Excel5");
$objPHPExcel = $objReader->load($dirTool."/A.xls");

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel5");
Nov 2, 2012 at 4:27 AM

Sorry,  one code miss , A.xls -> A_Result.xls is right.

and i still have this problem.

Nov 2, 2012 at 9:14 AM

phpexcel can only swrite features it supports to a file, and macro's are not one of them. I'm afraid what you want is not possible!

Nov 8, 2012 at 1:41 AM

but i just want to reserve macro, not modify it........

Nov 8, 2012 at 10:50 PM

I'm sorry, but as PHPExcel has no code to read or write macros, then this is not possible

Nov 9, 2012 at 3:02 PM

Mark, do you have a project in this area, or it's "mission impossible", within the framework defined by willcox?
Nov 9, 2012 at 4:57 PM

Technically it's possible, but many man-months of work... and a lower priority than many other feature requests

Nov 12, 2012 at 7:20 AM

Thanks for responding, Mark.
For a little watching, the differences appear to be, for an Excel 2007 file in relationship files, content, and the presence of a vbaProject.bin file, customizing the Ribbon adds also some elements, so work also to manage.