|
@@ -811,6 +811,10 @@ if (!function_exists('excelSaveBatch')) {
|
|
|
{
|
|
|
|
|
|
$urls = [];
|
|
|
+ $dir = root_path() . 'public/storage/report/' . date("YmdHis") . "/";
|
|
|
+ if (!is_dir($dir)) {
|
|
|
+ mkdir($dir, 0777, true);
|
|
|
+ }
|
|
|
foreach ($datas as $item) {
|
|
|
|
|
|
$objPHPExcel = new PHPExcel();
|
|
@@ -842,10 +846,7 @@ if (!function_exists('excelSaveBatch')) {
|
|
|
$file = $item['filename'] . ".xls";
|
|
|
|
|
|
|
|
|
- $dir = root_path() . 'public/storage/report/' . date("YmdHis") . "/";
|
|
|
- if (!is_dir($dir)) {
|
|
|
- mkdir($dir, 0777, true);
|
|
|
- }
|
|
|
+
|
|
|
$objPHPExcel->setActiveSheetIndex(0);
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
|
|
$objWriter->save($dir . $file);
|
|
@@ -863,25 +864,24 @@ if (!function_exists('excelSaveBatch')) {
|
|
|
mkdir($saveDir, 0777, true);
|
|
|
}
|
|
|
|
|
|
- $datetime = date("Y-m-d H:i:s");
|
|
|
+ $datetime = date("YmdHis");
|
|
|
$file_dir = $saveDir . $datetime . ".zip";
|
|
|
|
|
|
$zip = new \ZipArchive ();
|
|
|
|
|
|
- if ($zip->open($file_dir, \ZipArchive::OVERWRITE) !== true && $zip->open($file_dir, \ZipArchive::CREATE) !==
|
|
|
- true) echo '无法打开文件或者文件创建失败';
|
|
|
+ if ($zip->open($file_dir, \ZipArchive::OVERWRITE) !== true && $zip->open($file_dir, \ZipArchive::CREATE) !== true) echo '无法打开文件或者文件创建失败';
|
|
|
|
|
|
|
|
|
+
|
|
|
foreach ($urls as $fileName) {
|
|
|
- $zip->addEmptyDir($fileName);
|
|
|
+ @$zip->addFile($fileName);
|
|
|
}
|
|
|
|
|
|
- @$zip->addFile($url, $fileName . DIRECTORY_SEPARATOR . basename($url));
|
|
|
|
|
|
$zip->close();
|
|
|
|
|
|
- @deldir($dir);
|
|
|
-
|
|
|
+ @deldir($dir);
|
|
|
+
|
|
|
if (!file_exists($file_dir)) echo '压缩包文件不存在';
|
|
|
|
|
|
ob_clean();
|
|
@@ -892,8 +892,8 @@ if (!function_exists('excelSaveBatch')) {
|
|
|
header("Content-Type: application/octet-stream");
|
|
|
header("Content-Transfer-Encoding: binary");
|
|
|
header('Content-Length: ' . filesize($file_dir));
|
|
|
- readfile($file_dir);
|
|
|
- @ unlink($file_dir);
|
|
|
+ readfile($file_dir);
|
|
|
+ @unlink($file_dir);
|
|
|
exit();
|
|
|
}
|
|
|
}
|