Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

PHPExcel not working with PHP 7.0 #716

Closed
Ajtak opened this issue Oct 31, 2015 · 31 comments
Closed

PHPExcel not working with PHP 7.0 #716

Ajtak opened this issue Oct 31, 2015 · 31 comments

Comments

@Ajtak
Copy link

Ajtak commented Oct 31, 2015

Hi.
Is possible fix PHPExcel for working with PHP 7.0?

In actual version is error:

Fatal error: 'break' not in the 'loop' or 'switch' context in <mypath>\PHPExcel\PHPExcel\Calculation\Functions.php on line 581

Please fix this. Thank you.

@MarkBaker
Copy link
Member

It will be fixed before the release of PHP7

@niklas-heer
Copy link

Since PHP7 is officially released now and out of interest - does it now work?

@MarkBaker
Copy link
Member

All the more serious issues with PHP7 have been addressed in develop branch, and I've been running tests against that. The only things not working are those related to external libraries (jpgraph and various pdf rendering libraries), although phan is still picking up a few warnings about syntax that won't break anything, but still need cleaning up.

@iainfogg
Copy link

iainfogg commented Jan 7, 2016

Hi @MarkBaker - just wondered if there are any more timescales for a release containing the PHP7 work that you've done?

@iainfogg
Copy link

Hi @MarkBaker - are you able to give any update on this please?

It'd be helpful to know if the PHP7 changes have made their way into the 1.8 branch, and also whether you feel it's all there now.

@tomzx
Copy link

tomzx commented Jan 16, 2016

I've been using 1.8.1 with PHP7 without any issues so far. I'm not using jpgraph nor any pdf rendering libraries though.

If you want more specific details about PHP7, I think it would be great to specify which features of PHPExcel you're making use of.

@Kelvinco
Copy link

Just delete the break on line 581, it has worked for me.

@iainfogg
Copy link

iainfogg commented Feb 3, 2016

Thanks @tomzx and @Kelvinco

In truth, the application is huge, and has a lot of usages of PHPExcel which, in truth, I'm not familiar with.

I appreciate the tweak suggested and your feedback about what you've used successfully, I was just hoping that @MarkBaker or someone could provide an update as to the developers' view of whether it's now compatible, and ideally sorted that line deletion that @Kelvinco suggested rather than me doing my own hacks.

Otherwise, I have to do loads of digging myself into an application which is big and not that pretty!

@iainfogg
Copy link

iainfogg commented Feb 3, 2016

PS the application I was referring to is ours, the one that uses PHPExcel - not slating PHPExcel!

@naturekzw
Copy link

where is the phpexcell 1.8.1? @tomzx

@MarkBaker
Copy link
Member

@naturekzw - under the tagged releases - PHPExcel 1.8.1

@NazarenoMarzetti
Copy link

Hi.

I've a problem with the command
$objWriter->save('php://output');

not working in php7.

The same code workin in php5.5 but when i changed the version, the program die at this row.

Thanx.

Nazareno

@efantinij
Copy link

Hi NazarenoMarzetti,

on Line 581 of file PHPExcel/Classes/PHPExcel/Calculation/Functions.php there is a " break" , simply comment.

@PowerKiKi
Copy link
Member

This is solved in latest version of PHPExcel, 1.8.1.

@apurv195
Copy link

apurv195 commented Sep 25, 2017

Just comment the "break;" statement in functions.php file on Line No 581 (Working in PHP 7.1).

@xuxiaowenstyle
Copy link

not working with PHP 7.0.22 too,please tell me why?

@Toooooony
Copy link

@xuxiaowenstyle, I have no idea why. But a workaround is to go back to PHPExcel 1.8.0 and apply the manual fix on Functions.php.

@naturekzw
Copy link

@Toooooony PHPExcel 1.8.0 word well in PHP 7.1.9 at my project

@Toooooony
Copy link

@naturekzw Thanks, will keep it in mind. for now I have a site on AWS and some people has reported issues after updating to PHP7.1.x. So whatever works :)

@PowerKiKi
Copy link
Member

It is broken on PHP 7.1, and was only fixed in PHPOffice/PhpSpreadsheet@5df662e, not in PHPExcel.

@sideshowtoma
Copy link

okay guys i found a fix its dirty but it works,
go to Classes/PHPExcel/Writer/Excel2007.php

comment out the following lines, php 7 has a wierd return date type so doing this will enable php excel to work in php 7 pronto. any way

$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);

to

//$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
//PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
//PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);

worked for me.

@orcinus
Copy link

orcinus commented Dec 7, 2017

PHP Excel 1.8.1
Classes/PHPExcel/Worksheet/AutoFilter/Column.php
Lines 384 and 386

$this->$key[$k]
should be replaced with
$this->{$key[$k]}

to ensure backwards and forwards compatibility (5.x vs. 7.0).
See http://php.net/manual/en/migration70.incompatible.php, Changes to the handling of indirect variables, properties, and methods

@UBEX
Copy link

UBEX commented Dec 14, 2017

@orcinus Thats right! how we can resolve it? Finally i Think we shoud find an alternative to PHPExcel. Something declared full 100% compatible with PHP 7.0 or heighter (even better).

Any Idea?

@PowerKiKi
Copy link
Member

@UBEX you are looking for https://github.com/PHPOffice/PhpSpreadsheet

@UBEX
Copy link

UBEX commented Dec 14, 2017

@PowerKiKi Thanks. It is better in performance?

@PowerKiKi
Copy link
Member

It is next version of PHPExcel, so don't expect huge changes, but PHP 7 should give you a nice boost anyway.

@ghost
Copy link

ghost commented Jan 11, 2018

I had the same problem, and i downloaded de 1.8.1 version, i chanched the header, and it's work!

$objWriter = new PHPExcel_Writer_Excel2007($excel);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header("Content-Disposition: attachment;filename=report.xlsx");
header('Cache-Control: max-age=0');
$objWriter->save('php://output');

@sharadinfo
Copy link

sharadinfo commented Jun 25, 2018

hello guys.. i have php ci application. there import functionality. its work on local but not work on live.
php v7.1.9. if anyone have a solution please help me.

@ngogiang270593
Copy link

update PHPExcel : https://github.com/PHPOffice/PHPExcel.
Its Good.

@siQuang
Copy link

siQuang commented Aug 21, 2018

I just upgrade to PHP 7.1 and ran into this issue. Fix with installing zip.so, on centos 7 install "php-pecl-zip" extension and everything works for me. I'm on CentOS 7.5, PHP 7.1 with PHPExcel 1.8.1.

@PowerKiKi
Copy link
Member

PHPExcel is broken on PHP 7.1 and will never be fixed.

If you want to use PHP 7.1, you must migrate to PhpSpreadsheet or another project.

I am locking this thread to prevent users from giving incorrect/incomplete advice about PHP 7.1.

@PHPOffice PHPOffice locked as resolved and limited conversation to collaborators Aug 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests