无法为使用PhpExcel生成的.xlsm文件启用内容

无法为使用PhpExcel生成的.xlsm文件启用内容,excel,vba,phpspreadsheet,xlsm,phpexcel-1.8.0,Excel,Vba,Phpspreadsheet,Xlsm,Phpexcel 1.8.0,我正在尝试在现有的.xlsm模板上加载和写入内容,并将其另存为不同目录中的新文件。这些文件包含宏,宏需要像在原始文件中一样进行保护。为了得到结果,我在php中做了以下工作: <?php error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); require_once dirname(__FILE__) . '/ph

我正在尝试在现有的.xlsm模板上加载和写入内容,并将其另存为不同目录中的新文件。这些文件包含宏,宏需要像在原始文件中一样进行保护。为了得到结果,我在php中做了以下工作:

 <?php

    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);

    require_once dirname(__FILE__) . '/php_excel/Classes/PHPExcel.php';
    require_once dirname(__FILE__) . '/php_excel/Classes/PHPExcel/IOFactory.php';
    require_once dirname(__FILE__) . '/php_excel/Classes/PHPExcel/Reader/IReadFilter.php';
    date_default_timezone_set('Europe/London');

    $sheets = array('Welcome', 'Instructions', 'Data Definitions', 'Clothing');

    $inputFileName = __DIR__ . '/templates/Clothing.xlsm';

    $inputFileType = PHPExcel_IOFactory::identify($inputFileName);

    $this->PHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType);
    $sheetnames = $sheets;
    $this->PHPExcelReader->setLoadSheetsOnly($sheetnames);
    $this->PHPExcel = $this->PHPExcelReader->load($inputFileName);


    $this->PHPExcel->setActiveSheetIndex(3);

    // Redirect output to a client’s web browser (Excel2007)
    ob_end_clean();
    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition: attachment;filename="test.xlsm"');
    header('Cache-Control: max-age=0');

    $objWriter = PHPExcel_IOFactory::createWriter($this->PHPExcel, 'Excel2007');
    ob_end_clean();
    $objWriter->save($this->filename);

    $this->PHPExcel->disconnectWorksheets();
    unset($this->PHPExcel);