全局默认样式
设置全局默认样式,将会影响所有写入单元格的样式;

函数原型

1
defaultFormat(resource $formatHandler)
Copied!

resource $formatHandler

单元格样式

示例

1
$config = ['path' => './tests'];
2
$excel = new \Vtiful\Kernel\Excel($config);
3
4
$excel->fileName('tutorial.xlsx');
5
6
$format = new \Vtiful\Kernel\Format($excel->getHandle());
7
$colorOneStyle = $format
8
->fontColor(\Vtiful\Kernel\Format::COLOR_ORANGE)
9
->border(\Vtiful\Kernel\Format::BORDER_DASH_DOT)
10
->toResource();
11
12
$format = new \Vtiful\Kernel\Format($excel->getHandle());
13
$colorTwoStyle = $format
14
->fontColor(\Vtiful\Kernel\Format::COLOR_GREEN)
15
->toResource();
16
17
$filePath = $excel
18
// Apply the first style as the default
19
->defaultFormat($colorOneStyle)
20
->header(['hello', 'xlswriter'])
21
// Apply the second style as the default style
22
->defaultFormat($colorTwoStyle)
23
->data([
24
['hello', 'xlswriter'],
25
])
26
->output();
Copied!