简体   繁体   English

将 Html 表导出为 Excel in.xlsx 格式

[英]Export Html table to Excel in .xlsx format

Is it possible to export the table from Jsp to Excel in. xlsx format by setting ContentType.是否可以通过设置 ContentType.xlsx 格式将表格从 Jsp 导出到Excel格式。

    response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    response.setHeader("Content-Disposition", "attachment; filename="+filename+".xlsx");

It doesn't matter you are using jsp or not because once it is render than its simple plain html.你是否使用 jsp 并不重要,因为一旦它被渲染而不是简单的普通 html。 you can use table2excel plugin to convert it in excel format.您可以使用 table2excel 插件将其转换为 excel 格式。 only thing is that your table should be well formed.唯一的问题是你的桌子应该是正确的。

 $("#resultsTable").table2excel({
            exclude: ".noExl",
            name: "Results"
        });

here is working demo这是工作演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM