将数据导出Excel文件

    方法引用:

    1. \Phpcmf\Service::L('Phpexcel')->down_excel( $config, $field, $data);
    2. $config 参数配置
    3. $field 字段显示配置
    4. $data 具体数据

    示例参考:

    1. $data = [
    2. 0 => [ ... ],
    3. 1 => [ ... ],
    4. ];
    5.  
    6. $config = [
    7. 'author' => '作者', // 作者
    8. 'title' => '标题标题', // 标题
    9. 'border_color' => '000', // 表格框颜色
    10. 'head_bg_color' => 'eef1f5', // 头部背景颜色
    11. 'head_font_size' => '12', // 标题字体大小
    12. 'head_height' => 40, // 标题高度
    13. ];
    14.  
    15. $field = [
    16. 'A' => [
    17. 'name' => '范围', // 表格显示名称
    18. 'type' => 'text', // 显示方式
    19. 'field' => 'pid', // 对应字段名称
    20. 'width' => 10, // 宽度
    21. 'height' => 80, // 高度
    22. 'align' => 'left', // 居左显示,默认居中
    23. 'center' => 'true', // 是否居中对齐
    24. ],
    25. 'B' => [
    26. 'name' => '类型',
    27. 'type' => 'text',
    28. 'field' => 'tid',
    29. 'width' => 10,
    30. ],
    31. 'C' => [
    32. 'name' => '卡号',
    33. 'type' => 'text',
    34. 'field' => 'sn',
    35. 'width' => 30,
    36. ],
    37. 'D' => [
    38. 'name' => '密码',
    39. 'type' => 'text',
    40. 'field' => 'password',
    41. 'width' => 20,
    42. ],
    43. 'E' => [
    44. 'name' => '面额',
    45. 'type' => 'text',
    46. 'field' => 'value',
    47. 'width' => 15,
    48. ],
    49. 'F' => [
    50. 'name' => '时间',
    51. 'type' => 'text',
    52. 'field' => 'inputtime',
    53. 'width' => 15,
    54. ],
    55. 'G' => [
    56. 'name' => '二维码',
    57. 'type' => 'image', // 作为图片显示
    58. 'field' => 'ewm',
    59. 'width' => 15,
    60. 'image_height' => 60, // 图片高度
    61. 'image_x' => 20, // x坐标开始
    62. 'image_y' => 20, // y坐标开始
    63. ],
    64. ];
    65.  
    66. \Phpcmf\Service::L('Phpexcel')->down_excel( $config, $field, $data);

    文档最后更新时间:2018-09-19 12:46:44