zoukankan      html  css  js  c++  java
  • thinkphp导入

    编写简单的thinkphp导入的功能,大体的逻辑要自己编写。

    下面这些代码都是可以直接copy到你的代码里面的。

    set_time_limit(0);  //括号里边的数字是执行时间,如果为零说明永久执行直到程序结束,如果为大于零的数字,则不管程序是否执行完成,到了设定的秒数,程序结束。 
    ini_set('memory_limit', '500M');  //
    /*创建PHPEXCLE读取,默认excel2007,最好兼容csv格式*/
    import("ORG/PHPExcel/PHPExcel");
    //$filePath = '/home/t/桌面/10-27帐号额度.xls'; 
    $filePath =$_FILES['file']['tmp_name'];
    $PHPReader = new PHPExcel_Reader_Excel2007();
    if (!$filePath) {
    echo "<h1 style='color: red'> file don't exist! </h1>";
    return;
    }
    if (!$PHPReader->canRead($filePath)) {
    $PHPReader = new PHPExcel_Reader_Excel5();
    if (!$PHPReader->canRead($filePath)) {
    $PHPReader = new PHPExcel_Reader_CSV();
    if (!$PHPReader->canRead($filePath)) {
    echo 'no Excel';
    return;
    }
    }
    }
    $PHPExcel = $PHPReader->load($filePath);

    $currentSheet = $PHPExcel->getSheet(0);

    /*取得一共有多少列*/
    $allColumn = $currentSheet->getHighestColumn();
    /*取得一共有多少行*/
    $allRow = $currentSheet->getHighestRow();

  • 相关阅读:
    线段树
    数学建模中的excel操作
    POJ 3666 Making the Grade
    POJ 1742 Coins
    CF 55D
    POJ 3280 Cheapest Palindrome
    牛客 处女座与复读机
    牛客 处女座的约会
    牛客 小a与星际探索
    POJ 2229 递推
  • 原文地址:https://www.cnblogs.com/kobigood/p/4070569.html
Copyright © 2011-2022 走看看