protobi / js-xlsx

XLSX / XLSM / XLSB (Excel 2007+ Spreadsheet) / ODS parser and writer
http://oss.sheetjs.com/js-xlsx
Other
814 stars 416 forks source link

how to set cell to bold for specific columns? #131

Open paigeflourin opened 5 years ago

paigeflourin commented 5 years ago

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);
pietersv commented 5 years ago

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

paigeflourin commented 5 years ago

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.