Phpspreadsheet: XSLM Workbook - macro logic is removed when file is written to.

Created on 13 Jun 2017  路  4Comments  路  Source: PHPOffice/PhpSpreadsheet

I have a excel macro enabled workbook with custom macros. Our users can access a website and a there is a download process which populates the sheets of the workbook with data and downloads the complete book.

What is the expected behavior?

When writing to a xlsm workbook with empty sheets, the original macro's should remain after writing the file.

What is the current behavior?

It seems the original macro VBA details are getting stripped from the file when it's written to the php:output stream

What are the steps to reproduce?

See the code below

<?php

// load the workbook
$spreadsheet = PhpOffice\PhpSpreadsheet\IOFactory::load("BHAA.Race.Master.xlsm");

// create a writer instance
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx");

// set the headers
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Content-Disposition: attachment; filename=05featuredemo.xlsm");
header("Pragma: no-cache");
header("Expires: 0");

// write to the output stream
$writer->save('php://output');

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet: dev-develop
PHP: 5.6.30

duplicate

Most helpful comment

Any update?

All 4 comments

The root cause seems to be a duplicate of #170

Any news ?

Any Update?

Any update?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

noxidsoft picture noxidsoft  路  3Comments

Typel picture Typel  路  5Comments

huichen2017 picture huichen2017  路  4Comments

Blacknife picture Blacknife  路  4Comments

leandrogm picture leandrogm  路  5Comments