Clone and write .xlsm

Topics: Developer Forum
May 7, 2013 at 7:20 AM
I can not clone and write in .xlsm file.
I found this
https://phpexcel.codeplex.com/workitem/19017
but not working.

Does PHPexcel can clone .xlsm file and edit? I do not want edit macros.
May 7, 2013 at 11:30 AM
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 12:14 PM
Hi, this is code
/** Error reporting /
error_reporting(E_ALL);
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');
$objWriter->save('testing.xlsm');
header('Cache-Control: max-age=0');
code testing on .xlsm file https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=phpexcel&WorkItemId=19017&FileAttachmentId=6903
and I want only clone .xlsm file...
May 8, 2013 at 1: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?