Export To Excel a div content using Javascript/Jquery

I am trying to export div data which using JavaScript. It is exported to Excel but without css. No border is showing in Excel format, even I am not able to give name of Excel file.

Here is my code:

function ExportToExcel() {
    var contents = $(".divclass").html();
    window.open('data:application/vnd.ms-excel,' + encodeURIComponent(contents));
}
$("#btnExport").click(function(e) {
  let file = new Blob([$('.divclass').html()], {type:"application/vnd.ms-excel"});
let url = URL.createObjectURL(file);
let a = $("<a />", {
  href: url,
  download: "filename.xls"}).appendTo("body").get(0).click();
  e.preventDefault();
});