Clone and write .xlsm

Topics: Developer Forum
May 7, 2013 at 8:20 AM
I can not clone and write in .xlsm file.
I found this
but not working.

Does PHPexcel can clone .xlsm file and edit? I do not want edit macros.
May 7, 2013 at 12:30 PM
Officially, PHPExcel supports not macros.

One "does not work" is not a great help to correct the problem that there may be in the patch. There's error messages? The added methods give an unexpected result (see the example given)? Making available a sample workbook may aid in the diagnosis.
May 7, 2013 at 1:14 PM
Hi, this is code
/** Error reporting /
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/ PHPExcel_IOFactory /
require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Load from Excel2007 template" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("templates/testing_macro.xlsm");
echo ('Saving...');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
header('Cache-Control: max-age=0');
code testing on .xlsm file
and I want only clone .xlsm file...
May 8, 2013 at 2:19 PM
Using the supplied workbook and your code (proper close of comment line 1, adding a tag of opening php, adaptation of the paths to my environment), I get a workbook where the small macro functions (dialog box "Hi!").
When you run the script, do you have errors? Is a file produced? If so, that contains (before opening with Excel)?
If you add after the load() :
if($objPHPExcel->hasMacros()) echo 'macros in file',EOL; else echo 'No macros in file', EOL;
What answer gives the test?