简体   繁体   English

从位于多个div下的多个表中的JSP页面向Excel动态数据

[英]Dynamic Data to Excel from a JSP page residing in multiple tables under multiple div

I have a JSP Page containing multiple div's and multiple tables in those multiple div's . 我有一个JSP页面,其中包含多个div和这些多个div中的多个表。 I am using AJAX call to render data to those tables ie data in those tables are rendered dynamically . 我正在使用AJAX调用将数据呈现到那些表,即那些表中的数据是动态呈现的。 Now I have to export all that div tables to excel file , but I am unable to do that. 现在,我必须将所有div表导出到excel文件,但是我无法做到这一点。 My sample code for JSP page that renders data is : 我的呈现数据的JSP页面的示例代码是:

<script>
AJAX method to load data 
</script>

    <div class="xyz">
            <div class="abc">
                <div class="UserInfo">
                    </br><h2>User Info</h2></br>    

                    <table class="table-class">
                            <tr>
                                <td class="label" style='width: 25px'>Venue</td>
                                <td class="data"><label id="comptvl_itenary_venue"></label></td>
                            </tr>
                    </table>
                </div>
            </div>
        </div>

... some more div here with more tables in same format above. ...这里有更多的div,上面的表格格式也更多。 Now what I have to do is that I have to export all those multiple div resided table data to excel file . 现在我要做的是将所有这些多个div驻留表数据导出到excel文件。 For that I have used application/vnd.ms-excel as content type but it only generates excel when table data is static and not contain any CSS , otherwise it will copy whole table code in excel report. 为此,我使用了application / vnd.ms-excel作为内容类型,但是它仅在表数据为静态并且不包含任何CSS时才生成excel,否则它将在excel报告中复制整个表代码。 I have tried java script function too from this reference 我也从此参考资料中尝试过Java脚本功能

http://jsfiddle.net/AnilAwadh/cCzqn/4/

but it also generates excel when my table does not contain any CSS . 但是当我的表不包含任何CSS时,它也会生成excel。 Please guide me how can I export dynamic data generated in table containing CSS to excel. 请指导我如何将包含CSS的表中生成的动态数据导出到excel。

Thanks In Advance 提前致谢

rather than trying to export the data from the HTML, export the data when you load it (from the Ajax call). 而不是尝试从HTML导出数据,而是在加载数据时(从Ajax调用)导出数据。 If you have an "export to Excel" button (or whatever) this can reference the pre-saved excel. 如果您有“导出到Excel”按钮(或其他按钮),则可以引用预先保存的Excel。

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

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