600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > phpexcel读取excel表格时间的例子

phpexcel读取excel表格时间的例子

时间:2021-02-17 16:03:22

相关推荐

phpexcel读取excel表格时间的例子

php教程|php手册

explode

php教程-php手册

phpexcel是php中专业来操作excel表格的一个php插件了,下文我们就来看看phpexcel读取excel表格时间的例子,希望下文能够帮助到各位。

币胜源码,ubuntu的目录结果,tomcat 去除验证码,全民喝水爬虫,php实时刷新数据,seo黑帽正确使用方法引流推广lzw

编辑通过excel表格修改了大批的产品价格和促销时间,让我们技术批量导入到线上数据库。

wordpress源码讲解,ubuntu里cd,查找tomcat版本号,高村爬虫屋,php字符串排序函数,沈阳综合抖音seo优化报价行情lzw

这样对于我们来说是一件在简单不过的事情了,保护phpexcel导表利器,瞬间解决问题。

asp源码 企业黄页,vscode配置推荐,ubuntu 降温,tomcat端口超时,sqlite删除数据过慢,php在线办公插件,前端框架有哪些开发平台,树木防爬虫用什么方法,php 获取json数据,免费A漫seo,zblog蓝色简洁企业网站模板,手机在线网页源代码,童装网站模板lzw

可是,进入数据库一看:蒙了,导入的时间格式有问题,展示的不是时间,是数字,郁闷中。

然后通过php输出,果然不是时间的格式。

百度一遍发现,phpexcel里面提供了这样的方法getFormattedValue()来读出时间的,将getValue()换成

getFormattedValue();

$abc = $currentSheet->getCell ( ‘A’ . $currentRow )->getFormattedValue ();

这样就可以顺利的读出excel表里的时间,重新更新数据库,OK。

下面看个例子

load($inputFileName);$sheet = $objPHPExcel->getSheet(0);$highestRow = $sheet->getHighestRow(); // 取得总行数$highestColumn = $sheet->getHighestColumn(); // 取得总列数$tempArray = array();for ($j = 2; $j <= $highestRow; $j++) { for ($k = A; $k getActiveSheet()->getCell("$k$j")->getValue()); else $tempArray[] = $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue(); } print_r($tempArray); unset($tempArray);}function excelTime($date, $time = false) { if (function_exists(GregorianToJD)) { if (is_numeric($date)) { $jd = GregorianToJD(1, 1, 1970); $gregorian = JDToGregorian($jd + intval($date) - 25569); $date = explode(/, $gregorian); $date_str = str_pad($date[2], 4, , STR_PAD_LEFT) . "-" . str_pad($date[0], 2, , STR_PAD_LEFT) . "-" . str_pad($date[1], 2, , STR_PAD_LEFT) . ($time ? " 00:00:00" : \); return $date_str; } } else { $date = $date > 25568 ? $date + 1 : 25569; /*There was a bug if Converting date before 1-1-1970 (tstamp 0)*/ $ofs = (70 * 365 + 17 + 2) * 86400; $date = date("Y-m-d", ($date * 86400) - $ofs) . ($time ? " 00:00:00" : \); } return $date;}

本文链接:

收藏随意^^请保留教学地址.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。