Issues (23)

example/import.php (1 issue)

Labels
Severity
1
<?php
2
use tinymeng\spreadsheet\TSpreadSheet;
3
4
require __DIR__.'/../vendor/autoload.php';
5
6
/**
7
 * excel生成文件名
8
 */
9
$filename = './export_demo.xlsx';
10
/**
11
 * excel表头
12
 */
13
$title = [
14
    '序号'=>'id',
15
    '订单编号'=>'order_sn',
16
    '用户id'=>'user_id',
17
    '结算日期'=>'day',
18
    '下单时间'=>'create_time',
19
    '图片'=>'images',
20
];
21
22
//1. 读取并初始化表格内容数据
23
//$TSpreadSheet = TSpreadSheet::import()
24
//    ->initWorkSheet($filename);//读取并初始化表格内容数据
25
26
//2. 读取带图片并初始化表格内容数据
27
$path = './uploads/imgs/'.date('Ymd', time());//excel中图片本地存储路径
28
$TSpreadSheet = TSpreadSheet::import()
0 ignored issues
show
The call to tinymeng\spreadsheet\TSpreadSheet::import() has too few arguments starting with config. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
$TSpreadSheet = TSpreadSheet::/** @scrutinizer ignore-call */ import()

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
29
    ->initWorkSheet($filename)//读取并初始化表格内容数据
30
    ->setRelativePath($path)->setImagePath($path);// 设置将excel中图片本地存储
31
32
//3. 设置title对应字段,获取表格内容
33
$data = $TSpreadSheet->setTitle($title)->getExcelData();
34
var_dump($data);die;
35
/**
36
 * array(3) {
37
 * [0]=>
38
 * array(3) {
39
 * ["id"]=>
40
 * string(1) "1"
41
 * ["order_sn"]=>
42
 * string(14) "20180101465464"
43
 * ["create_time"]=>
44
 * string(19) "2023-06-19 10:06:16"
45
 * }
46
 * [1]=>
47
 * array(3) {
48
 * ["id"]=>
49
 * string(1) "2"
50
 * ["order_sn"]=>
51
 * string(14) "20190101465464"
52
 * ["create_time"]=>
53
 * string(19) "2023-06-19 10:06:16"
54
 * }
55
 * [2]=>
56
 * array(3) {
57
 * ["id"]=>
58
 * string(1) "3"
59
 * ["order_sn"]=>
60
 * string(14) "20200101465464"
61
 * ["create_time"]=>
62
 * string(19) "2023-06-19 10:06:16"
63
 * }
64
 * }
65
 */
66
67
68
//4. 也可以设置读取第几个sheet
69
//$TSpreadSheet = TSpreadSheet::import()
70
//    ->setFileName($filename)//读取文件路径
71
//    ->setSheet(0)//读取第0个sheet
72
//    ->setTitleRow(1)//表头所在行
73
//    ->initWorkSheet($filename);