-
Notifications
You must be signed in to change notification settings - Fork 1
5. 表格设置
ogenes edited this page Apr 23, 2023
·
2 revisions
可以直接设置默认宽度
$client->setStyleWidth(50);
$client->setStyleUnit('');
分别设置每列的宽度在 config 中设置 width 属性即可。
$config['sheet1'] = [
['bindKey' => 'goodsName', 'columnName' => '商品名称', 'width' => 40 ],
['bindKey' => 'price', 'columnName' => '售价', 'format' => NumberFormat::FORMAT_DATE_YYYYMMDDSLASH],
['bindKey' => 'actualStock', 'columnName' => '实际库存'],
];
$client->setFreezeHeader(true);
$client->setAutoFilter(true);
$client->serProtection(true);
这里非必要不建议使用自定义缓存,自定义缓存会导致导出变慢,且一定不要用主业务的redis,如果导出过程中程序异常终止,phpspreadsheet不会释放redis空间,
$redis = new Redis();
$redis->connect('redis');
$client->setRedis($redis);