js-xlsx icon indicating copy to clipboard operation
js-xlsx copied to clipboard

how to set cell to bold for specific columns?

Open paigeflourin opened this issue 5 years ago • 2 comments

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);

paigeflourin avatar Mar 28 '19 03:03 paigeflourin

the library currently sets styles cell by cell. OpenXML also allows styles by row and column but that's not currently implemented.

pietersv avatar Mar 28 '19 03:03 pietersv

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.

paigeflourin avatar Mar 28 '19 03:03 paigeflourin