TextXLSXArray logic
calculate TextXLSXArray[File, File, ...] from csv[File, File, ...] via inlineStr.define
1. declare chunks,chunks=[
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>`
,`<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">`
+`<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>`
+`<Default Extension="xml" ContentType="application/xml"/>`
+`<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>`
,i=>`<Override PartName="/xl/worksheets/sheet${1+i}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`
,`</Types>`
,`<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`
+`<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>`
+`</Relationships>`
,`<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>`
,fs=>(names=>i=>{
const name=names[i]
if(31<name.length||name.match(/[/?*\[\]:']/)||!name||names.lastIndexOf(name)!==i)throw new Error()
return`<sheet name="${name.toXMLAttribute()}" sheetId="${1+i}" r:id="rId${1+i}"/>`
})(map(false,fs,f=>f.name.replace(/\.[^/.]+$/,``)))
,`</sheets></workbook>`
,`<Relationships xmlns="http://schemas.openxmlformats.org/officeDocument/2006/relationships">`
,i=>`<Relationship Id="rId${1+i}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${1+i}.xml"/>`
,`</Relationships>`
,`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>`
,r=>`<row r="${r}">`
,(r,v,i)=>`<c r="${new Col(i).alphabet.toUpperCase()}${r}" t="inlineStr"><is><t>${v}</t></is></c>`
,`</row>`
,`</sheetData></worksheet>`
]2. declare values, declaration
const vs=Array(4+fs.length),declaration=encoder.encode(chunks[0])3. declare getFile
,getFile=async(v,c)=>{
let controller
const blob=new Response(new ReadableStream({
start:v=>{controller=v}
})).blob()
controller.enqueue(declaration)
await c(v=>controller.enqueue(encoder.encode(v)))
controller.close()
const file=new File([await blob],v[1])
Reflect.defineProperty(file,`webkitRelativePath`,{value:v[0]+v[1]})
return file
}4. set [Content_Types].xml
vs[0]=await getFile(targets[0],enqueue=>enqueue(chunks[1])||forEach(false,fs.length,(_,i)=>enqueue(chunks[2](i)))||enqueue(chunks[3]))5. set _rels/.rels
vs[1]=await getFile(targets[1],enqueue=>enqueue(chunks[4]))6. set xl/workbook.xml
vs[2]=await getFile(targets[2],enqueue=>enqueue(chunks[5])||(c=>forEach(false,fs.length,(_,i)=>enqueue(c(i))))(chunks[6](fs))||enqueue(chunks[7]))7. set xl/_rels/workbook.xml.rels
vs[3]=await getFile(targets[3],enqueue=>enqueue(chunks[8])||forEach(false,fs.length,(_,i)=>enqueue(chunks[9](i)))||enqueue(chunks[10]))8. set xl/worksheets/sheet{n}.xml
await forEach(true,fs.length,async(_,i)=>vs[4+i]=await getFile(targets[4](i),async enqueue=>{
enqueue(chunks[11])
const scanner=new Scanner(decoder,fs[i].stream())
for(let r=0;null!=await scanner.findInLine(`[^\r\n]+`);){
enqueue(chunks[12](++r))
forEach(false,scanner.match()[0].splitFrom(`"(?:""|[^"])*"|[^,]+`),(v,i)=>undefined===v||undefined===(v=chunks[13](r,v.replace(/^"(.*)"$|^$/s,`$1`).replace(/""/g,`"`).toXMLText(),i))||enqueue(v))
enqueue(chunks[14])
}
enqueue(chunks[15])
}))9. return
return vs