// Offline XLSX fixture used only by download-center contract tests. export function exportWorkbook(headers, values = []) { const escape = value => String(value ?? '').replace(/&/g, '&').replace(//g, '>') const rows = [headers, values].map((row, index) => `${row.map((value, col) => { const letter = String.fromCharCode(65 + col) return `${escape(value)}` }).join('')}`).join('') const name = Buffer.from('xl/worksheets/sheet1.xml') const body = Buffer.from(`${rows}`) const local = Buffer.alloc(30) local.writeUInt32LE(0x04034b50); local.writeUInt32LE(body.length, 18); local.writeUInt32LE(body.length, 22); local.writeUInt16LE(name.length, 26) const central = Buffer.alloc(46) central.writeUInt32LE(0x02014b50); central.writeUInt32LE(body.length, 20); central.writeUInt32LE(body.length, 24); central.writeUInt16LE(name.length, 28) const end = Buffer.alloc(22) end.writeUInt32LE(0x06054b50); end.writeUInt16LE(1, 8); end.writeUInt16LE(1, 10) end.writeUInt32LE(central.length + name.length, 12); end.writeUInt32LE(local.length + name.length + body.length, 16) return Buffer.concat([local, name, body, central, name, end]) }