| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkPHP [ WE CAN DO IT JUST THINK ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 流年 <liu21st@gmail.com>
- // +----------------------------------------------------------------------
- use PhpOffice\PhpSpreadsheet\Spreadsheet;
- use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
- use PhpOffice\PhpSpreadsheet\Reader\Xls;
- use PhpOffice\PhpSpreadsheet\IOFactory;
- use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
- use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
- use PhpOffice\PhpSpreadsheet\Cell\DataType;
- use PhpOffice\PhpSpreadsheet\Style\Fill;
- use PhpOffice\PhpSpreadsheet\Style\Color;
- use PhpOffice\PhpSpreadsheet\Style\Alignment;
- use PhpOffice\PhpSpreadsheet\Style\Border;
- use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
- // 应用公共文件
- /**
- * 删除目录以及其下的文件
- * @param $directory
- * @return bool
- */
- function removeDir($directory)
- {
- if (false == is_dir($directory)) {
- return false;
- }
- $handle = opendir($directory);
- while (false !== ($file = readdir($handle))) {
- if ('.' != $file && '..' != $file) {
- is_dir("$directory/$file") ? removeDir("$directory/$file") : @unlink("$directory/$file");
- }
- }
- if (readdir($handle) == false) {
- closedir($handle);
- rmdir($directory);
- }
- return true;
- }
- function Kfid($uid)
- {
- return trim($uid, 'KF');
- }
- function kfUid($id)
- {
- return 'KF' . $id;
- }
- //数组转为健的数组
- function kftoKey($uidArray, $type = 0)
- {
- $return = [];
- foreach ($uidArray as $val) {
- if ($type == 0) {
- $return[$val] = 0;
- } elseif ($type == 1) {
- $return[$val] = [];
- } else {
- $return[$val] = $val;
- }
- }
- return $return;
- }
- //保留小数位数
- function floatPointDigit($data, $long = 2)
- {
- $long = intval($long);
- $for1 = "%." . $long . "f";
- $for2 = "%." . ($long + 1) . "f";
- return sprintf($for1, substr(sprintf($for2, $data), 0, -1));
- }
- //秒格式化为 小时分秒
- function secendToHourMinit($sec)
- {
- $array = ['h' => 0, 'm' => 0, 's' => 0];
- $sec = intval($sec);
- $array['h'] = floor($sec / 3600);
- $array['m'] = floor(($sec - 3600 * $array['h']) / 60);
- $array['s'] = $sec - 3600 * $array['h'] - 60 * $array['m'];
- $return = '';
- if ($array['h']) {
- $return .= $array['h'] . '小时';
- }
- if ($array['m']) {
- $return .= $array['m'] . '分';
- }
- if ($array['s']) {
- $return .= $array['s'] . '秒';
- }
- return $return;
- }
- //小数转百分比显示
- function perDisplay($dit, $xiaos = 2)
- {
- return floatPointDigit(floor(100 * $dit), $xiaos) . '%';
- }
|