]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Сохранение файла bugfix_fomichev_ERP-422_fix-excel-file-export-product-actuality origin/bugfix_fomichev_ERP-422_fix-excel-file-export-product-actuality
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 11 Jun 2026 09:40:11 +0000 (12:40 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 11 Jun 2026 09:40:11 +0000 (12:40 +0300)
erp24/controllers/Products1cNomenclatureActualityController.php

index bce3403ca4fd216869d9f23fd93af5ebd3d7308b..bcaa7649e8c9df319c43ee0f318844c82a770e0e 100644 (file)
@@ -563,12 +563,18 @@ class Products1cNomenclatureActualityController extends Controller
         }
 
         $filename = 'actuality_' . date('Y-m-d') . '.xlsx';
-        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
-        header('Content-Disposition: attachment; filename="' . $filename . '"');
-        header('Cache-Control: max-age=0');
+        $tempFile = tempnam(sys_get_temp_dir(), 'xlsx_');
 
         $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
-        $writer->save('php://output');
+        $writer->save($tempFile);
+
+        Yii::$app->response->sendFile(
+            $tempFile,
+            $filename,
+            ['mimeType' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
+        )->send();
+
+        @unlink($tempFile);
         Yii::$app->end();
     }