\DtApp\ThinkLibrary\serviceExcelService

表格服务 Class ExcelService

Summary

Methods
Properties
Constants
__construct()
instance()
setHead()
setHeadLength()
setContent()
setFileName()
generate()
No public properties found
No constants found
initialize()
$app
N/A
No private methods found
$head
$head_length
$content
$file_name
N/A

Properties

$app

$app : \think\App

应用实例

Type

\think\App

$head

$head : array

头部

Type

array

$head_length

$head_length : array

头部长度

Type

array

$content

$content : array

内容

Type

array

$file_name

$file_name : string

文件名

Type

string

Methods

__construct()

__construct(\think\App  $app) 

Service constructor.

Parameters

\think\App $app

instance()

instance(array  $args) : static

静态实例对象

Parameters

array $args

Returns

static

setHead()

setHead(array  $head = array()) : \DtApp\ThinkLibrary\service\ExcelService

设置头部 [ [ [ 'index' => 1, 'value' => '标题' ], [ 'index' => 2, 'value' => '名称' ] ], [ [ 'index' => 1, 'value' => '标题2' ], [ 'index' => 2, 'value' => '名称2' ] ] ];

Parameters

array $head

Returns

\DtApp\ThinkLibrary\service\ExcelService

setContent()

setContent(array  $content = array()) : \DtApp\ThinkLibrary\service\ExcelService

设置内容 [ [ [ 'index' => 1, 'value' => '标题' ], [ 'index' => 2, 'value' => '名称' ] ], [ [ 'index' => 1, 'value' => '标题2' ], [ 'index' => 2, 'value' => '名称2' ] ] ];

Parameters

array $content

Returns

\DtApp\ThinkLibrary\service\ExcelService

setFileName()

setFileName(string  $file_name = '') : $this

设置文件名(不需要后缀名)

Parameters

string $file_name

Returns

$this

generate()

generate() : string

生成表格文件

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception
\think\Exception

Returns

string

initialize()

initialize() : $this

初始化服务

Returns

$this