Read XSLX is Changing Files Modification Date

Topics: User Forum
Sep 30, 2009 at 2:24 PM

I'm having a problem with PHP Excel 1.7.0 where reading the Excel file updates its modification date on the file system. Is it possible to use PHPExcel to read the XLSX data without updating the modification date?

I'm new to PHPExcel, so perhaps I'm making an obvious error.

$tracker = PHPExcel_IOFactory::load("data/cttdata.xlsx");

Is how I'm reading the file. This is Apache under Linux with PHP 5.2.10.

Thanks.

Developer
Sep 30, 2009 at 4:54 PM

>> Is it possible to use PHPExcel to read the XLSX data without updating the modification date?

This is strange. The reader is not supposed to change the dates on the file system.

Can you try to run the test with an xls file instead of an xlsx file and report back if the same thing is happening?

Oct 1, 2009 at 2:35 PM

XLS works properly. Also, it occurred to me that I am using the ZipArchive.php replacement on the server because the zip module is not enabled. Maybe that's causing the problem?

I've also cobbled together a very simple test that doesn't change the mod date for xls or xlsx.

/** ZIP */
if ($_SERVER['SERVER_NAME'] != 'localhost') {
require_once 'ZipArchive.php';
}

/** PHPExcel */
require_once 'PHPExcel.php';

/** PHPExcel_IOFactory */
require_once './PHPExcel/IOFactory.php';

print "Last Modified: " . date( "m/d/Y H:i:s.", filemtime("phpxldate.xlsx"));

$tracker = PHPExcel_IOFactory::load("PHPXLdate.xls");

$properties = $tracker->getProperties();
print date('m/d/Y', $properties->getModified() );

print "Last Modified: " . date( "m/d/Y H:i:s.", filemtime("phpxldate.xlsx"));

So it looks like reading properties doesn't change the mod date, but reading some other data does.

Coordinator
Oct 1, 2009 at 3:12 PM

You might want to rerun your tests calling clearstatcache() between the two calls to filemtime()

You may also want to test fileatime() as well