Thinkphp+phpexcel implementing a method to read a file date time and seconds

Source: Internet
Author: User
The example in this paper describes how Thinkphp+phpexcel implements the Read file date. Share to everyone for your reference, as follows:

When we read the Excel file using Phpexcel, we found that the time is similar to the number: 41890.620138889, then how to handle it as we want 2014-09-08 14:53:00 This format date, see the code:

Vendor (' PHPExcel.PHPExcel.IOFactory '); $inputFileName = ' Public/demo/demo.xls '; $objReader = new Phpexcel_reader_ Excel5 (); $objPHPExcel = $objReader->load ($inputFileName); $sheet = $objPHPExcel->getsheet (0); $highestRow = $ Sheet->gethighestrow (); Total number of rows $highestcolumn = $sheet->gethighestcolumn (); Total number of columns obtained $temparray = array (); for ($j =2; $j <= $highestRow; $j + +) {for  ($k = ' A '; $k <= $highestColumn; $k + +) {    if ($k = = ' h ') {//Specifies the column of H for      the time $tempArray [] = Gmdate ("y-m-d h:i:s", phpexcel_shared_date::exceltophp ($objPHPExcel- >getactivesheet ()->getcell ("$k $j")->getvalue ()));    } else{       $tempArray [] = $objPHPExcel->getactivesheet ()->getcell ("$k $j")->getvalue ();    }    echo "
";    Print_r ($tempArray);    Unset ($tempArray);    echo "
"; }}

The exceltophp function in the Phpexcel_shared_date class is a key part!

More interested in thinkphp related content readers can view this site topic: "thinkphp Introductory Tutorial", "thinkphp Common Method Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", " Summary of cookie Usage in PHP, basic tutorial on Smarty Templates and PHP template technology summary.

It is hoped that this article is helpful to the PHP program design based on thinkphp framework.

The above describes the Thinkphp+phpexcel implementation of the method to read the file date time and seconds, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.