?php
// Отдаем файл как старый Excel 97-2003 (.xls)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="fast_report_' . date('Y-m-d') . '.xls"');
header('Cache-Control: max-age=0');
// Начинаем вывод HTML-документа
?>
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://w3.org">
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />
<style>
/* Задаем стили через обычный CSS */
.header { background-color: #4CAF50; color: #FFFFFF; font-weight: bold; text-align: center; }
.warning { background-color: #FFEB3B; }
.cell { font-family: Arial; font-size: 10pt; }
</style>
</head>
<body>
<table border="1">
<!-- Шапка -->
<tr>
<td class="header">ID</td>
<td class="header">Товар</td>
<td class="header">Статус</td>
</tr>
<!-- Быстрый цикл вывода данных -->
<?php for ($i = 1; $i <= 50000; $i++):
$is_warning = ($i % 10 === 0); // Имитация условия для подсветки
$class = $is_warning ? 'warning' : 'cell';
?>
<tr>
<td class="<?=$class?>"><?=$i?></td>
<td class="<?=$class?>">Товар №<?=$i?></td>
<td class="<?=$class?>"><?=$is_warning ? 'Внимание' : 'ОК'?></td>
</tr>
<?php endfor; ?>
</table>
</body>
</html>