Xls
in package
Table of Contents
Properties
- $_format_val : mixed
- 取格式化表格内容
- $base_url : mixed
- $label : mixed
- $merge : mixed
- $sheet_width : mixed
- $start_line : mixed
- 解析时有用 title是第几行的,默认第一行是标题信息
- $title_index : mixed
- 读取时有用 title是第几行的,默认第一行是标题信息
- $works : mixed
Methods
- _sheet() : mixed
- 内部使用 处理每行值
- create() : string
- 生成XLSX $xls_titles = [ 'name' => '产品名称', 'sku_num' => '内部编号', ] $data = [ ['name'=>'test','sku_num'=>1001] ]
- getCol() : void
- 根据 列、行返回对应xls的key
- load() : mixed
- 导入XLSX文件,返回数组
- load_all() : array<string|int, mixed>
- 解析xlsx文件
- load_count() : mixed
Properties
$_format_val
取格式化表格内容
public
static mixed
$_format_val
= false
$base_url
public
static mixed
$base_url
= '/uploads/tmp/xls/'
$label
public
static mixed
$label
= ""
$merge
public
static mixed
$merge
$sheet_width
public
static mixed
$sheet_width
= []
$start_line
解析时有用 title是第几行的,默认第一行是标题信息
public
static mixed
$start_line
= 1
$title_index
读取时有用 title是第几行的,默认第一行是标题信息
public
static mixed
$title_index
= 1
$works
public
static mixed
$works
= []
Methods
_sheet()
内部使用 处理每行值
public
static _sheet(mixed &$sheet, mixed $xls_titles, mixed $data, mixed $options, mixed $sheet_width) : mixed
Parameters
- $sheet : mixed
- $xls_titles : mixed
- $data : mixed
- $options : mixed
- $sheet_width : mixed
create()
生成XLSX $xls_titles = [ 'name' => '产品名称', 'sku_num' => '内部编号', ] $data = [ ['name'=>'test','sku_num'=>1001] ]
public
static create(mixed $xls_titles, mixed $data, mixed $name[, mixed $is_output_to_brower = false ][, mixed $sheet_call = '' ]) : string
第一个worksheet Xls::$label = '专票'; Xls::$sheet_width = [ 'A' => "15", 'B' => "36", 'C' => "30", 'D' => "10", 'E' => "10", 'F' => "10", ];
更多worksheet,如果只是一个,可不用下面代码 Xls::$works = [ [ 'title' => $title, 'label' => '普票', 'data' => $new_data, 'width' => Xls::$sheet_width, ] ]; Xls::create($title, $values, $name, $is_output_to_brower = true);
Parameters
- $xls_titles : mixed
- $data : mixed
- $name : mixed
- $is_output_to_brower : mixed = false
- $sheet_call : mixed = ''
Return values
string —xls url
getCol()
根据 列、行返回对应xls的key
public
static getCol(int $start_row, int $start_col) : void
Parameters
- $start_row : int
-
开始行
- $start_col : int
-
开始列
Tags
load()
导入XLSX文件,返回数组
public
static load(mixed $file[, mixed $xls_row_1 = ['产品编号' => 'product_num', '产品规格' => 'name'] ][, mixed $column_use_date = [] ][, mixed $worksheet = '' ][, mixed $spreadsheet = '' ]) : mixed
Parameters
- $file : mixed
- $xls_row_1 : mixed = ['产品编号' => 'product_num', '产品规格' => 'name']
- $column_use_date : mixed = []
- $worksheet : mixed = ''
- $spreadsheet : mixed = ''
load_all()
解析xlsx文件
public
static load_all(string $file, mixed $row[, mixed $date = [] ][, mixed $worksheet_arr = [] ]) : array<string|int, mixed>
$lists = helper_v3\Xls::load($file, [ '产品编号' => 'product_num', '产品规格' => 'name', '注册证号' => 'cert_num', '单位' => 'unit', ]);
Parameters
- $file : string
-
本地文件
- $row : mixed
- $date : mixed = []
- $worksheet_arr : mixed = []
Return values
array<string|int, mixed>load_count()
public
static load_count(mixed $file) : mixed
Parameters
- $file : mixed