leruge/excel

提取Excel内容

Maintainers

Package info

gitee.com/leruge/tp-excel

pkg:composer/leruge/excel

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

dev-master 2026-08-14 10:16 UTC

This package is auto-updated.

Last update: 2026-08-14 10:17:04 UTC


README

支持提取图片,函数式图片和浮动图片都支持

安装

composer require leruge/excel

调用方法

  1. 类调用

    $excelUrl = '/Volumes/1TB/storage/hsl/20260814/a.xlsx'; // 本地绝对路径
    $headMap = [ // 表头对应的字段,空数组的时候提取的数据没有字段名
     '货号' => 'symbol',
     '条码' => 'no',
     '商品名称' => 'goods_name',
     '图片' => 'img',
    ];
    $imgPath = '/static/uploads/excel/'; // 提取图片的相对路径
    $info = \leruge\Excel::getData($excelUrl, $headMap, $imgPath);
    // $info 的结果是如写格式
    $info = [
     'headers' = ['货号', '条码', '商品名称'],
     'data', = [
         ['symbol' => '2026081401', 'no' => 'T081401', 'goods_name' => '富士苹果', 'img' => '/static/uploads/excel/20260814/6a7ee364d38c5.png'],
         ['symbol' => '2026081402', 'no' => 'T081402', 'goods_name' => '水晶葡萄', 'img' => '/static/uploads/excel/20260814/6a7ee364d5ca0.png']
     ]
    ];
    
  2. 助手函数调用

    $excelUrl = '/Volumes/1TB/storage/hsl/20260814/a.xlsx'; // 本地绝对路径
    $headMap = [ // 表头对应的字段,空数组的时候提取的数据没有字段名
     '货号' => 'symbol',
     '条码' => 'no',
     '商品名称' => 'goods_name',
     '图片' => 'img',
    ];
    $imgPath = '/static/uploads/excel/'; // 提取图片的相对路径
    $info = get_excel_data($excelUrl, $headMap, $imgPath);
    // $info 的结果是如写格式
    $info = [
     'headers' = ['货号', '条码', '商品名称'],
     'data', = [
         ['symbol' => '2026081401', 'no' => 'T081401', 'goods_name' => '富士苹果', 'img' => '/static/uploads/excel/20260814/6a7ee364d38c5.png'],
         ['symbol' => '2026081402', 'no' => 'T081402', 'goods_name' => '水晶葡萄', 'img' => '/static/uploads/excel/20260814/6a7ee364d5ca0.png']
     ]
    ];