add XLSX summary to the archive

This commit is contained in:
gapato 2026-06-11 15:29:52 +02:00
commit 7e135392a4
3 changed files with 51 additions and 0 deletions

View file

@ -243,6 +243,43 @@ function escapeCsvValue(value) {
return `"${stringValue.replace(/"/g, "\"\"")}"` return `"${stringValue.replace(/"/g, "\"\"")}"`
} }
const API_FIELD_MAP = {
"last_name": "Nachname",
"first_name": "Vorname",
"email": "E-Mail Adresse",
"telephone_number": "Telefonnummer",
"gender": "Geschlecht",
"academic_title_before_name": "Akademischer Grad vorangestellt",
"academic_title_after_name": "Akademischer Grad nachgestellt",
"professional_title": "Berufstitel",
"date_of_birth": "Geburtsdatum",
"highest_educational_degree": "Höchster Bildungsabschluss",
"highest_academic_education": "Höchster akademischer Abschluss",
"final_year_studies": "Letztes Studienjahr (Master oder PhD)",
"first_language": "Erstsprache",
"nationality_arr": "Staatsangehörigkeit",
"relevant_links": "Relevante Links",
"orcid_id": "ORCID ID",
"google_scholar_profile": "Google Scholar Profil",
"how_did_you_become_aware_arr": "Wie sind Sie auf die Stelle aufmerksam geworden?",
}
function createApplicantsXlsx(applicantDetailsList) {
const sorted_mapped = applicantDetailsList.sort((appli1, appli2) => {
appli1.last_name.localeCompare(appli2.last_name)
}).map((appli) => {
const mapped = {}
Object.keys(API_FIELD_MAP).forEach(key => {
mapped[API_FIELD_MAP[key]] = appli[key]
})
return mapped
})
const sheet = XLSX.utils.json_to_sheet(sorted_mapped)
const book = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(book, sheet, "Applications")
return new Uint8Array(XLSX.toXLSXBlob(book).buffer)
}
function createApplicantsCsv(applicantDetailsList) { function createApplicantsCsv(applicantDetailsList) {
const rows = [ const rows = [
CSV_FIELDS.join(",") CSV_FIELDS.join(",")
@ -523,6 +560,9 @@ function rip(event) {
console.log("Creating applications.csv") console.log("Creating applications.csv")
archiveEntries["applications.csv"] = createApplicantsCsv(successfulApplicants) archiveEntries["applications.csv"] = createApplicantsCsv(successfulApplicants)
console.log("Creating applications.xlsx")
archiveEntries["applications.xlsx"] = createApplicantsXlsx(successfulApplicants)
console.log("Creating index.html") console.log("Creating index.html")
archiveEntries["viewer.html"] = viewerHtmlSource archiveEntries["viewer.html"] = viewerHtmlSource

View file

@ -27206,6 +27206,7 @@ function write_zip_denouement(z, o) {
case "binary": oopts.type = "string"; break; case "binary": oopts.type = "string"; break;
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files"); case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
case "buffer": case "buffer":
case "blob":
case "file": oopts.type = ftype; break; case "file": oopts.type = ftype; break;
default: throw new Error("Unrecognized type " + o.type); default: throw new Error("Unrecognized type " + o.type);
} }
@ -27219,6 +27220,7 @@ function write_zip_denouement(z, o) {
/*jshint -W083 */ /*jshint -W083 */
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o); // eslint-disable-line no-undef if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o); // eslint-disable-line no-undef
/*jshint +W083 */ /*jshint +W083 */
if(o.type === "blob") return out
if(o.type === "file") return write_dl(o.file, out); if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out; return o.type == "string" ? utf8read(out) : out;
} }
@ -27345,6 +27347,13 @@ function resolve_book_type(o) {
o.bookType = _BT[o.bookType] || o.bookType; o.bookType = _BT[o.bookType] || o.bookType;
} }
function toXLSXBlob(wb, filename, opts) {
var o = opts||{};
o.type = 'blob';
o.bookType = 'xlsx';
return writeSync(wb, o);
}
function writeFileSync(wb, filename, opts) { function writeFileSync(wb, filename, opts) {
var o = opts||{}; o.type = 'file'; var o = opts||{}; o.type = 'file';
o.file = filename; o.file = filename;
@ -28078,6 +28087,7 @@ XLSX.readFile = readFileSync; //readFile
XLSX.readFileSync = readFileSync; XLSX.readFileSync = readFileSync;
XLSX.write = writeSync; XLSX.write = writeSync;
XLSX.writeFile = writeFileSync; XLSX.writeFile = writeFileSync;
XLSX.toXLSXBlob = toXLSXBlob;
XLSX.writeFileSync = writeFileSync; XLSX.writeFileSync = writeFileSync;
XLSX.writeFileAsync = writeFileAsync; XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils; XLSX.utils = utils;

View file

@ -25,6 +25,7 @@
], ],
"js": [ "js": [
"lib/fflate.min.js", "lib/fflate.min.js",
"lib/xlsx.js",
"content.js" "content.js"
], ],
"css": [ "css": [