|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55715 Iterating Excel worksheet cell values may crash PHP
Submitted: 2011-09-17 15:20 UTC Modified: 2011-11-24 13:33 UTC
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: ystsoi at yahoo dot com dot hk Assigned:
Status: Duplicate Package: COM related
PHP Version: 5.4.0beta1 OS: Windows XP SP3, Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
43 + 48 = ?
Subscribe to this entry?

 [2011-09-17 15:20 UTC] ystsoi at yahoo dot com dot hk
When run the following test script, PHP will crash when it tries to get the value of the second cell.

The problem will not occur if Cells() is not used within the for-loop.

Test script:
$excel = new COM("Excel.Application");
$worksheet = $excel->ActiveSheet;
for ($j = 1; $j <= 2; $j++) {
	echo $worksheet->Cells(1, $j)->Value, "\n";

Expected result:
The values of A1 and B1 in test.xls will be echoed.

Actual result:
Only the value of A1 in test.xls is echoed, then crash.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-11 00:07 UTC] lunter at interia dot pl
Confirmed on PHP 5.4.0 RC1, Apache 2.2.21 VC9
Windows 7 32bit

Bug introduced in PHP 5.4
PHP 5.3.8 works fine.
 [2011-11-12 09:40 UTC] bugzilla33 at gmail dot com
Expected result:
PHP 5.3.9RC1 prints: Microsoft Windows

Actual result:
PHP 5.4.0RC1 crash


  $o=new COM('WinMgmts:',null,CP_UTF8);
  foreach($o->ExecQuery('SELECT * FROM Win32_OperatingSystem') as $x){


 [2011-11-24 13:33 UTC]
-Status: Open +Status: Duplicate
 [2011-11-24 13:33 UTC]
The patch in bug #60167 fixes this, also. Pending review for commit, this should be in 5.4.0RC2.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Apr 02 03:03:39 2023 UTC