原文安装链接:https://github.com/Maatwebsite/Laravel-Excel

代码如下:

        if ($rows = DB::connection('glist')->table('program_view')->where('v_type', $type)->get())
{
$head = array('Pid', 'Name', 'Play Times');
$height = array();
$movie_prog = array();
$movie_height = array();
$series_prog = array();
$series_height = array(); foreach ($rows as $row)
{
$pro_pid = $row->v_pid;
$pro_name = $row->v_prog;
$play_time = 0; if ($counts = DB::connection('glist')->table('program_date_view')->where('prog_id', $pro_pid)
->whereBetween('date', array($start_time, $end_time))->lists('view_count'))
{
foreach ($counts as $count)
{
$play_time += $count;
}
} $play_times[] = strval($play_time);
$prog[] = array($pro_pid, $pro_name, strval($play_time)); if (isset($this->mMonitorProgTypes[$pro_pid]) &&
self::VOD_PROGRAM_TYPE == $this->mMonitorProgTypes[$pro_pid] &&
isset($this->mMonitorProgCategories[$pro_pid]) &&
"Series" != $this->mMonitorProgCategories[$pro_pid])
{
$movie_play_times[] = strval($play_time);
$movie_prog[] = array($pro_pid, $pro_name, strval($play_time));
}
else if (isset($this->mMonitorProgTypes[$pro_pid]) &&
self::VOD_PROGRAM_TYPE == $this->mMonitorProgTypes[$pro_pid] &&
isset($this->mMonitorProgCategories[$pro_pid]) &&
"Series" == $this->mMonitorProgCategories[$pro_pid])
{
$series_play_times[] = strval($play_time);
$series_prog[] = array($pro_pid, $pro_name, strval($play_time));
}
} if (!empty($prog))
{
array_multisort($play_times, SORT_DESC, $prog);
array_unshift($prog, $head);
$height = array_fill(0, count($prog) + 1, 20); //20——excel cell height
} if (!empty($movie_prog))
{
array_multisort($movie_play_times, SORT_DESC, $movie_prog);
array_unshift($movie_prog, $head);
$movie_height = array_fill(0, count($movie_prog) + 1, 20);
} if (!empty($series_prog))
{
array_multisort($series_play_times, SORT_DESC, $series_prog);
array_unshift($series_prog, $head);
$series_height = array_fill(0, count($series_prog) + 1, 20);
}
} Excel::create($type . ' Program Statistics Data', function($excel) use ($type, $prog, $height, $movie_prog, $movie_height, $series_prog, $series_height) { $excel->sheet('program_ranking', function($sheet) use ($prog, $height) { $sheet->fromArray($prog, null, 'A1', false, false);
$sheet->setWidth(array('A' => 25, 'B' => 35, 'C' => 15));
$sheet->setHeight($height); $sheet->cells('A1:C1', function ($cells) {
$cells->setFont(array(
'family' => 'Calibri',
'size' => '14',
'bold' => true
));
}); $sheet->cells('A1:C' . count($height), function ($cells) {
$cells->setAlignment('center');
$cells->setValignment('middle');
});
}); if ("VOD" == $type)
{
$excel->sheet('series_ranking', function($sheet) use ($series_prog, $series_height) { $sheet->fromArray($series_prog, null, 'A1', false, false);
$sheet->setWidth(array('A' => 25, 'B' => 35, 'C' => 15));
$sheet->setHeight($series_height); $sheet->cells('A1:C1', function ($cells) {
$cells->setFont(array(
'family' => 'Calibri',
'size' => '14',
'bold' => true
));
}); $sheet->cells('A1:C' . count($series_height), function ($cells) {
$cells->setAlignment('center');
$cells->setValignment('middle');
});
}); $excel->sheet('other_ranking', function($sheet) use ($movie_prog, $movie_height) { $sheet->fromArray($movie_prog, null, 'A1', false, false);
$sheet->setWidth(array('A' => 25, 'B' => 35, 'C' => 15));
$sheet->setHeight($movie_height); $sheet->cells('A1:C1', function ($cells) {
$cells->setFont(array(
'family' => 'Calibri',
'size' => '14',
'bold' => true
));
}); $sheet->cells('A1:C' . count($movie_height), function ($cells) {
$cells->setAlignment('center');
$cells->setValignment('middle');
});
});
}
})->export('xls');
}

laravel安装excel功能的更多相关文章

  1. laravel安装Excel安装不上

    1.生明版本号 composer require maatwebsite/excel 2.1我的PHP是7.0安装Excel得2.1 2.在composer.json中加入 "maatweb ...

  2. laravel 安装excel扩展

    1,使用Composer安装依赖 在Laravel项目根目录下使用Composer安装依赖: composer require maatwebsite/excel ~2.1 ps:一定要加上~2.1! ...

  3. laravel实现excel表的导入导出功能

    1.这是个我去公司之后曾经折磨我很久很久的功能查阅了很多资料但是功夫不负有心人在本人的不懈努力下还是实现了这个功能 (ps看不懂我下面说讲述的可以参考这个laravel学院的官方文档 https:// ...

  4. 项目笔记:导出Excel功能

    1.前台这块: var ids=""; $.post("${basePath}/assets/unRegDeviceAction_getDeviceIds.do" ...

  5. laravel基础课程---1、laravel安装及基础介绍(laravel如何安装)

    laravel基础课程---1.laravel安装及基础介绍(laravel如何安装) 一.总结 一句话总结: [修改composer镜像地址].[明确laravel的安装要求].[安装指定版本的la ...

  6. vue项目导出EXCEL功能

    因为一些原因导出EXCEL功能必须前端来做,所以就研究了一下,在网上也找了一些文章来看,有一些不完整,我做完了就记录下来,供大家参考: 1.首先先安装依赖: npm install file-save ...

  7. Laravel安装方法 (windows)

    Laravel安装方法(windows) 安装PHP 下载PHP7 http://windows.php.net/download#php-7.0 进入上述网站下载PHP7 选择zip包解压安装 配置 ...

  8. virtualbox安装增强功能时【未能加载虚拟光盘】

    virtualbox安装增强功能时[未能加载虚拟光盘] 今天在使用Virtualbox中的Ubuntu虚拟机,想安装增强功能来实现更改分辨率,但是在安装时出错:未能加载虚拟光驱 VBoxsGuestA ...

  9. laravel安装学习步骤

    在看知乎比较php框架的优劣的时候提到为什么laravel这么好国内用的少,还有就是yii2,有人提到原因就是composer在国内无法使用.这制约了使用composer进行包管理的框架在国内的传播和 ...

随机推荐

  1. iOS多线程中performSelector

    下面两段代码都在主线程中运行,我们在看别人代码时会发现有时会直接调用,有时会利用performSelector调用,今天看到有人在问这个问题,我便做一下总结, [delegate imageDownl ...

  2. linux内核移植到S5pv210

    make s5pv210_defconfig 1.System Type  ---> (0) S3C UART to use for low-level messages 2.Kernel ha ...

  3. jdk,tomcat配置

    方法/步骤 一.安装JDK和Tomcat 1,安装JDK:直接运行jdk-7-windows-i586.exe可执行程序,默认安装即可. 备注:路径可以其他盘符,不建议路径包含中文名及特殊符号. 2. ...

  4. Codeforces 691A Fashion in Berland

    水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #includ ...

  5. PVST+(每个VLAN 的生成树PVST 加)

    PVST+(每个VLAN 的生成树PVST 加) 实验拓扑: 分别在 SW1 和SW2 上show spanning-tree 查看结果: SW1#show spanning-tree VLAN000 ...

  6. android使用support的ActionBar时遇到的问题

    多从网上下载好了support library之后,把android-support-v7-appcompat.jar放到了libs目录下,并加入到了编译路径,本以为万事大吉,可是却报了下面的一个错误 ...

  7. C# 经典入门12章-使用泛型类型-2

  8. Java-老夫对泛型的理解。。

    什么是泛型,在我看来 泛型就是能够限制类,方法,数组-变量的类型 比如说  List<String,int> list = new List<String,int> 就是有尖括 ...

  9. 转: OGG Checkpoint 详解

    1. OGG Checkpoint 详解 定位中断的位置,下次启动从中断的位置开始恢复. 1.target 端配置: 2.一条记录对应一个replicat 一. Extract Checkpoints ...

  10. HDOJ1312<DFS>

    题意: 给一张图,有墙,有路.问某人从起点开始,最多能走多少个格子. 思路: bfs;<水题> #include<iostream> #include<cstring&g ...