viest / php-ext-xlswriter

🚀 PHP Extension for creating and reader XLSX files.
https://xlswriter.viest.me
BSD 2-Clause "Simplified" License
2.25k stars 232 forks source link

当文件名中包含英文冒号时临时文件无法创建 #498

Closed xiaopp closed 9 months ago

xiaopp commented 9 months ago
$config = [
    'path' => $this->getTmpDir() . '/',
];

$suffix = empty($params['format']) ? 'xlsx' : 'csv';
$fileName   = '导出_' . date('Y-m-d H:i:s') . '.' . $suffix;
$xlsxObject = new \Vtiful\Kernel\Excel($config);

时间去掉冒号就能创建,加上就不行

Windows PHP7.4.13 xlswriter 1.5.5

viest commented 9 months ago

尝试将文件名转为UTF-8试试:

$fileName = '导出_' . date('Y-m-d H:i:s') . '.' . $suffix;
$fileName = mb_convert_encoding($fileName, 'UTF-8', mb_detect_encoding($fileName));
xiaopp commented 9 months ago

还是不行,后续的filesize方法会报错,filesize(): stat failed for C:\Users\USER\AppData\Local\Temp/导出_2023-11-19 17:11:46.csv,应该是没读取到临时文件导致的

qihengsan89 commented 9 months ago

windows文件名不是不允许包含英文冒号吗

qihengsan89 commented 9 months ago

image

xiaopp commented 9 months ago

我知道了,我以前用的maatwebsite/excel会自动把冒号转换成下划线,我没注意到,抱歉