enable AutoFilter and set reasonable column widths in XLSX
This commit is contained in:
parent
4a4f316ce6
commit
2f5077f2e8
1 changed files with 15 additions and 0 deletions
15
content.js
15
content.js
|
|
@ -264,6 +264,8 @@ const API_FIELD_MAP = {
|
||||||
"how_did_you_become_aware_arr": "Wie sind Sie auf die Stelle aufmerksam geworden?",
|
"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) {
|
function createApplicantsXlsx(applicantDetailsList) {
|
||||||
const sorted_mapped = applicantDetailsList.sort((appli1, appli2) => {
|
const sorted_mapped = applicantDetailsList.sort((appli1, appli2) => {
|
||||||
appli1.last_name.localeCompare(appli2.last_name)
|
appli1.last_name.localeCompare(appli2.last_name)
|
||||||
|
|
@ -275,6 +277,19 @@ function createApplicantsXlsx(applicantDetailsList) {
|
||||||
return mapped
|
return mapped
|
||||||
})
|
})
|
||||||
const sheet = XLSX.utils.json_to_sheet(sorted_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()
|
const book = XLSX.utils.book_new()
|
||||||
XLSX.utils.book_append_sheet(book, sheet, "Applications")
|
XLSX.utils.book_append_sheet(book, sheet, "Applications")
|
||||||
return new Uint8Array(XLSX.toXLSXBlob(book).buffer)
|
return new Uint8Array(XLSX.toXLSXBlob(book).buffer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue