From 2f5077f2e86f5fbf00a3c1d29008df45b2ac4eaa Mon Sep 17 00:00:00 2001 From: gapato Date: Fri, 12 Jun 2026 10:26:19 +0200 Subject: [PATCH] enable AutoFilter and set reasonable column widths in XLSX --- content.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/content.js b/content.js index 92ef34d..3919889 100644 --- a/content.js +++ b/content.js @@ -264,6 +264,8 @@ const API_FIELD_MAP = { "how_did_you_become_aware_arr": "Wie sind Sie auf die Stelle aufmerksam geworden?", } +const COL_WIDTHS = [ 17, 20.03, 33.45, 17.25, 12.95, 31.43, 38.52, 12.57, 15.73, 55.23, 31.68, 35.35, 37.63, 20.29, 191.81, 11.68, 21.17, 45.73 ] + function createApplicantsXlsx(applicantDetailsList) { const sorted_mapped = applicantDetailsList.sort((appli1, appli2) => { appli1.last_name.localeCompare(appli2.last_name) @@ -275,6 +277,19 @@ function createApplicantsXlsx(applicantDetailsList) { return mapped }) const sheet = XLSX.utils.json_to_sheet(sorted_mapped) + + // enable easy filtering, sorting + sheet["!autofilter"] = { ref: `A1:R${applicantDetailsList.length}` } + + // set basic column widths + + /* create !cols array */ + sheet["!cols"] = []; + + COL_WIDTHS.forEach((width, idx) => { + sheet["!cols"][idx] = { width }; + }) + const book = XLSX.utils.book_new() XLSX.utils.book_append_sheet(book, sheet, "Applications") return new Uint8Array(XLSX.toXLSXBlob(book).buffer)