【问题标题】:Can Jsreport client asynchronous send and receive xlsx file?Jsreport客户端可以异步收发xlsx文件吗?
【发布时间】:2018-03-15 04:52:50
【问题描述】:

我想使用jsreport 浏览器将数据发送到服务器并以 xlsx 文件的形式下载回来。

使用jsreport.download(request) 会限制数据量,因为它是一个 GET。我可以像使用 pdf 一样使用jsreport.renderAsync() 下载 xlsx 文件吗?

【问题讨论】:

    标签: asynchronous get xlsx jsreport


    【解决方案1】:

    jsreport.renderAsync 在 promise ArrayBuffer 中返回。您可以将其转换为 blob,然后使用saveAs 将其下载到用户计算机。

    <script async="" src="https://cdn.rawgit.com/eligrey/FileSaver.js/e9d941381475b5df8b7d7691013401e171014e89/FileSaver.min.js"></script>
    
    <script>
        jsreport.renderAsync({
            template: {
                content: '<table><tr><td>foo</td></tr></table>',
                engine: 'none',
                recipe: 'html-to-xlsx'
            }
        }).then(function (res) {
            var dataView = new DataView(res);
            var blob = new Blob([dataView], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
            saveAs(blob, 'a.xlsx')
        })
    </script>
    

    https://playground.jsreport.net/studio/workspace/HJ0z0yaY/8

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多