0) { $number--; $name = chr(65 + ($number % 26)) . $name; $number = intdiv($number, 26); } return $name; } function cell(string $reference, string $value, int $style): string { return '' . esc($value) . ''; } $sheetRows = []; $sheetRows[] = '' . cell('A1', 'Document No: Work Schedule', 1) . cell('B1', 'Project: BRN WMS', 1) . cell('C1', 'Project Code: 200-WMS-26-001-00', 1) . cell('D1', 'Period: 05-Jan-2026 to 14-Aug-2026', 1) . cell('E1', 'Release: 05/01/26 V1.0 Final', 1) . ''; $sheetRows[] = ''; foreach ($headers as $index => $header) { $sheetRows[1] .= cell(colName($index + 1) . '2', $header, 2); } $sheetRows[1] .= ''; foreach ($rows as $rowIndex => $row) { $excelRow = $rowIndex + 3; $xml = ''; foreach ($row as $columnIndex => $value) { $style = $columnIndex === 9 ? ($value === 'Completed' ? 4 : 5) : ($columnIndex === 0 || $columnIndex >= 5 && $columnIndex <= 7 ? 3 : 6); $xml .= cell(colName($columnIndex + 1) . $excelRow, $value, $style); } $sheetRows[] = $xml . ''; } $lastRow = count($rows) + 2; $sheet = '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . implode('', $sheetRows) . '' . '' . '' . '' . '&LISO/IEC 29110&C200-WMS-26-001-00&RPage &P of &N' . ''; $styles = '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . ''; $contentTypes = '' . '' . '' . '' . '' . '' . ''; $rootRels = '' . '' . '' . ''; $workbook = '' . '\'Work Schedule\'!$A$1:$K$' . $lastRow . ''; $workbookRels = '' . '' . ''; $core = '200-WMS-26-001-00 Work ScheduleBRN WMS Project TeamISO/IEC 29110 reconstructed final project schedule ready for authorization.2026-01-05T00:00:00+07:00'; $app = 'Microsoft ExcelB.R.N. Enterprise Co., Ltd.'; $zip = new ZipArchive(); if ($zip->open($output, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) { throw new RuntimeException('Cannot create ' . $output); } foreach (['[Content_Types].xml' => $contentTypes, '_rels/.rels' => $rootRels, 'xl/workbook.xml' => $workbook, 'xl/_rels/workbook.xml.rels' => $workbookRels, 'xl/worksheets/sheet1.xml' => $sheet, 'xl/styles.xml' => $styles, 'docProps/core.xml' => $core, 'docProps/app.xml' => $app] as $name => $contents) { $zip->addFromString($name, $contents); } $zip->close(); echo $output . PHP_EOL; require __DIR__ . '/normalize_document_dates.php';