简体   繁体   中英

issue with excel import ms excel

While importing excel using ms excel file not working gettting this error

Array ( [0] => 42000 [1] => 1065 [2] => Query was empty ) 
Warning: A non-numeric value encountered in C:\xampp\htdocs\Classes\PHPExcel\Shared\Date.php on line 135

Warning: A non-numeric value encountered in C:\xampp\htdocs\Classes\PHPExcel\Shared\Date.php on line 136

Warning: A non-numeric value encountered in C:\xampp\htdocs\Classes\PHPExcel\Shared\Date.php on line 137

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\Classes\PHPExcel\CachedObjectStorage\CacheBase.php on line 196

date.php

 if ($dateValue >= 1) {
            $utcDays = $dateValue - $myexcelBaseDate;
            $returnValue = round($utcDays * 86400);
            if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
                $returnValue = (integer) $returnValue;
            }
        } else {
            $hours = round($dateValue * 24);
            $mins = round($dateValue * 1440) - round($hours * 60);
            $secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
            $returnValue = (integer) gmmktime($hours, $mins, $secs);
        }

But it's working for libre office.Any help would be appreciated.

i think you could just cast to an int $dateValue = (int)$dateValue;

im asuming the lines below the else are the 135, 136, 137

if ($dateValue >= 1) {
    $utcDays = $dateValue - $myexcelBaseDate;
    $returnValue = round($utcDays * 86400);
    if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
        $returnValue = (integer) $returnValue;
    }
} else if ($dateValue < 0){
    $dateValue = (int)$dateValue;
    $hours = round($dateValue * 24);
    $mins = round($dateValue * 1440) - round($hours * 60);
    $secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
    $returnValue = (integer) gmmktime($hours, $mins, $secs);
}

Also, sometimes you gotta increase the execution time, you can do it this way:

set_time_limit(60); // 60 seconds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM