数字格式化

函数原型

1
number(string $format): self
Copied!

string $format

数组格式字符串
1
"0.000"
2
"#,##0"
3
"#,##0.00"
4
"0.00"
Copied!

示例

1
$config = [
2
'path' => './tests'
3
];
4
5
$fileObject = new \Vtiful\Kernel\Excel($config);
6
7
$fileObject = $fileObject->fileName('tutorial.xlsx');
8
$fileHandle = $fileObject->getHandle();
9
10
// 创建样式资源
11
$format = new \Vtiful\Kernel\Format($fileHandle);
12
$numberStyle = $format->number('#,##0')->toResource();
13
14
$filePath = $fileObject->header(['name', 'balance'])
15
->data([
16
['viest', 10000],
17
['wjx', 100000]
18
])
19
->setColumn('B:B', 50, $numberStyle) // 应用样式
20
->output();
Copied!
Last modified 2yr ago