<?php
<?php
$config = ['path' => './'];
$excel = new \Vtiful\Kernel\Excel($config);
$fileObject = $excel->fileName("tutorial01.xlsx");
$fileHandle = $fileObject->getHandle();
// 方式一:写入数据时应用文本格式
// $fileObject->header(['电话', '身份证'])
// ->data(
// [
// [strval(138001380354511), '110101199003072345'],
// [strval(138001380354512), '110101199003072346'],
// [(string) 138001380354513, '110101199003072347'],
// [138001380354514, '110101199003072348'],
// ]
// )
// ->output();
$fileObject->header(['姓名', '电话', '身份证'])
->setColumn('A:A', 20, $textFormat) // 设置A列为文本格式
->setColumn('B:B', 20, $textFormat); // 设置B列为文本格式;
$content = [];
// 生成1000条测试数据
for ($i = 1; $i <= 1000; $i++) {
$temp_data = [
'张三' . mt_rand(100, 999), // 姓名
strval('1' . mt_rand(100, 999) . mt_rand(100, 999) . mt_rand(1000, 9999)), // 电话
'1101011990030' . mt_rand(10000, 99999) // 身份证
];
$content[] = $temp_data;
}
// 方式二
for($ii = 0; $ii < sizeof($content); $ii ++){
for($tt = 0; $tt < sizeof($content[$ii]); $tt ++){
$fileObject->insertText($ii, $tt, strval($content[$ii][$tt]), '@');
}
}
$fileObject->output();
// 关闭文件句柄
// $fileObject->close();
?>
?>
02-28
1304
1304
11-16
1729
1729
12-13
1218
1218
12-03
312
312

被折叠的 条评论
为什么被折叠?



