sheetjs icon indicating copy to clipboard operation
sheetjs copied to clipboard

[SOLVED] making bold cells, align text to the right

Open smalljam opened this issue 11 years ago • 10 comments

Hey guys, thank you for amazing work you are doing. From what I see bold cell is most requested feature and I needed ability to align text to the right, so made a quick and dirty patch — https://gist.github.com/smalljam/b0e8b7a7e5a218b58e62#file-xlsx-patch there is also test.js example with data structure, where you can use bold: true and 'alignRight: true' Maybe someone will find this usable. Thanks. Anton.

smalljam avatar Aug 19 '15 09:08 smalljam

So how to apply this patch to existing js-xlsx?

Suncatcher avatar Nov 13 '17 15:11 Suncatcher

I'm not sure it's still relevant for up-to-date version of js-xlsx, I've used "custom" version with patch from above applied by hands :)

smalljam avatar Nov 14 '17 08:11 smalljam

I'm not sure it's still relevant for up-to-date version of js-xlsx, I've used "custom" version with patch from above applied by hands :)

I think it's relevant. Bolding and aligning are still not available in main branch.

Suncatcher avatar Nov 14 '17 08:11 Suncatcher

please let me know if you will be able to apply it to current version, good luck!

smalljam avatar Nov 14 '17 09:11 smalljam

@smalljam ur solution works for me.. thanks a tonn 👍

pankajnagarsekar avatar Jan 02 '18 07:01 pankajnagarsekar

@pankajnagarsekar How you appled patch let me know please??

Krishnakanth94 avatar Apr 30 '18 13:04 Krishnakanth94

@krishnakanth94 I replaced the code in min.js. that's it

pankajnagarsekar avatar Apr 30 '18 17:04 pankajnagarsekar

We offer this in the Pro compendium. Since companies have paid for the features already, it would be unfair to them if we turned around and made it available as open source. We have a longer comment in a gist.

SheetJSDev avatar May 20 '18 17:05 SheetJSDev

hi @smalljam ,

may i get help in applyin it to my application? i need to set the cell values for the specific column but my code looks like this;

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

and i need to set these columns under (header 9-15) bold

image

paigeflourin avatar Mar 28 '19 03:03 paigeflourin

hi @smalljam ,

may i get help in applyin it to my application? i need to set the cell values for the specific column but my code looks like this;

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

and i need to set these columns under (header 9-15) bold

image

if anyone find the solution let us know ,i am also facing same issue

samgodar64 avatar Apr 09 '19 05:04 samgodar64