How to add cell border to SheetJS .xlsx generated file?

Roberto Sepúlveda Bravo picture Roberto Sepúlveda Bravo · May 1, 2018 · Viewed 12.3k times · Source

I have a SheetJS .xlsx generated file, but I have not been able to put border to the cells.

I have this:

enter image description here

And I need this:

enter image description here

Is there a way to do it with SheetJS? It will be cool if there's a way to apply another cell styles, like background color.

EDIT:

I'm making the sheets with this function:

function makeSheet(wb, day){        //sheet for a specific day
    var ws = XLSX.utils.table_to_sheet(document.getElementById("table"+day));
    wb.SheetNames.push(day);
    wb.Sheets[day] = ws;
    //columns width working ok
    wb["Sheets"][day]["!cols"] = [{ wpx : 70 },{ wpx : 121 }];
    //wb["Sheets"][day]["A1"]["s"] = {"border":"1px"};  //I've tried this but doesn't work
  return wb;
}

EDIT 2

I've created this example snippet, if you can put borders and/or another cell style here, that's going to be a victory:

Answer

Vikasdeep Singh picture Vikasdeep Singh · May 30, 2018

You are using community version of SheetJS library and with this version can not do styling. BUT in Pro Version styling feature is available.

Checkout this official comment:

This is the community version. We also offer a pro version with performance enhancements, additional features like styling, and dedicated support.

For more information about Pro Version visit their official site: http://sheetjs.com/pro