js-xlsx
js-xlsx copied to clipboard
how to set cell to bold for specific columns?
i am using SheetJS/js-xlsx and i need to set the cell values to bold for specific columns. this is how i generate my excel, my data source is an array
let excelCols = rowData;
/* cell width */
var wscols = [];
let cell;
for (let i = 0; i < excelCols.length; i++) {
wscols.push({ wch: 20 }); // wch = character
}
/* convert state to workbook */
const ws = XLSX.utils.aoa_to_sheet(xlsData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "SheetJS");
ws['!cols'] = wscols;
/* generate XLSX file */
const wbout = XLSX.write(wb, { type: "array", bookType: "xlsx" });
/* send to client */
let fileName = "Report" + moment().format('YYYYMMDDhhmmss') + ".xlsx";
saveAs(new Blob([wbout], { type: "application/octet-stream" }), fileName);
the library currently sets styles cell by cell. OpenXML also allows styles by row and column but that's not currently implemented.
the library currently sets styles cell by cell. OpenXML also allows styles by row and column but that's not currently implemented.
so with my current implementation i cannot set the style of the cell? my data source is an array.