javascript excellentexport blob问题

javascript excellentexport blob问题,javascript,blob,excellentexport,Javascript,Blob,Excellentexport,我有一个网页,可以生成一个包含1000-5000条记录(14列)的报告。守则: excel: function(anchor, table, name) { table = get(table); var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}; var hrefvalue = uri.excel + base64(format(template.excel, c

我有一个网页,可以生成一个包含1000-5000条记录(14列)的报告。守则:

excel: function(anchor, table, name) {
        table = get(table);
        var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML};
        var hrefvalue = uri.excel + base64(format(template.excel, ctx));
        anchor.href = hrefvalue;
        // Return true to allow the link to work
        return true;
    },
如果记录是1500条左右,这是可行的,但如果超过2000条,则不可行。我看到了这篇文章,并试图将其与我的代码结合起来:

var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML};

var blob = b64toBlob(ctx, "application/vnd.ms-excel");
var blobUrl = URL.createObjectURL(blob);
window.location = blobUrl;

function b64toBlob(b64Data, contentType, sliceSize) {
    contentType = contentType || '';
    sliceSize = sliceSize || 512;

    var byteCharacters = atob(b64Data);
    var byteArrays = [];

    for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
        var slice = byteCharacters.slice(offset, offset + sliceSize);

        var byteNumbers = new Array(slice.length);
        for (var i = 0; i < slice.length; i++) {
            byteNumbers[i] = slice.charCodeAt(i);
        }

        var byteArray = new Uint8Array(byteNumbers);

        byteArrays.push(byteArray);
    }

    var blob = new Blob(byteArrays, {type: contentType});
    return blob;
}
var ctx={工作表:名称| |'工作表',表:table.innerHTML};
var blob=b64toBlob(ctx,“应用程序/vnd.ms excel”);
var blobUrl=URL.createObjectURL(blob);
window.location=blobUrl;
函数b64toBlob(b64Data、contentType、sliceSize){
contentType=contentType | |“”;
切片大小=切片大小| | 512;
var byteCharacters=atob(b64Data);
var ByteArray=[];
对于(变量偏移量=0;偏移量
我现在可以导出超过2000条记录的记录,但当我打开电子表格时,它还会将菜单、报告按钮、文本框导出到excel中,并且我需要的报告的开头将位于第150行的某个位置,其中包含导出的所有额外内容


有没有办法删除也在excel中导出的UI?

我只是想在黑暗中拍摄一下-我对代码的工作原理不太了解<代码>获取(),格式(),模板.excel对于许多人来说是未知的,我们很难帮助您

但我认为你必须这样做:

excel: function(anchor, table, name) {
  table = get(table);
  var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML};
  var data = format(template.excel, ctx)
  var blob = new Blob([data], {type: "application/vnd.ms-excel"})
  var url = URL.createObjectURL(blob)
  anchor.href = url;
  anchor.download = 'file.xlsx'
  // Return true to allow the link to work
  return true;
}
顺便说一句,试着完全拧紧base64-这是一种糟糕的做法

我推荐的另一件事是