简体   繁体   English

将数据表中的隐藏列导出到 Excel

[英]Export Hidden Column in DataTable to Excel

I am new in javascript.我是 javascript 新手。 I have used datatable like below in my PHP application.我在我的 PHP 应用程序中使用了如下所示的数据表。 All is working fine.一切正常。 I have made some column hidden in table due to space issue.由于空间问题,我在表格中隐藏了一些列。 I want export all columns with excel.我想用excel导出所有列。 Currently its only exporting visible columns.目前它仅导出可见列。

        <table class='table-striped' id='questions'
                                data-toggle="table"
                                data-url="get-list.php?table=question"
                                data-click-to-select="true"
                                data-side-pagination="server"
                                data-pagination="true"
                                data-page-list="[5, 10, 20, 50, 100, 200]"
                                data-search="true" data-show-columns="true"
                                data-show-refresh="true" data-trim-on-search="false"
                                data-sort-name="id" data-sort-order="desc"
                                data-mobile-responsive="true"
                                data-toolbar="#toolbar" data-show-export="true"
                                data-maintain-selected="true"
                                data-export-types='["txt","excel"]'
                                data-export-options='{
                                    "fileName": "questions-list-<?=date('d-m-y')?>",
                                    "ignoreColumn": ["state","IMAGE_FILE","operate"],



                                }'
                                data-query-params="queryParams_1"
                                >
                                <thead>
                                    <tr>
                                        <th data-field="state" data-checkbox="true"></th>
                                        <th data-field="ID" data-sortable="true">ID</th>
                                        <th data-field="R_DATE" data-sortable="true" data-visible='false'>R DATE</th>
                                        <th data-field="Q_NUM" data-sortable="true" data-visible='false'>Q NUM</th>
                                        <th data-field="HIDDEN_IMAGE" data-visible="false">IMAGE</th>
                                        <th data-field="IMAGE_FILE" data-sortable="false">Image</th>
                                        <th data-field="Q_TYPE" data-sortable="true">Q TYPE</th>
                                        <th data-field="SOURCE_TYPE" data-sortable="true">S TYPE</th>
                                        <th data-field="SOURCE" data-sortable="true">SOURCE</th>
                                        <th data-field="S_CAT" data-sortable="true">S CAT</th>
                                        <th data-field="CAT" data-sortable="true">CAT</th>

                                        <th data-field="QUESTION" data-sortable="true">Question</th>
                                        <th data-field="A1" data-sortable="true">A1</th>
                                        <th data-field="A2" data-sortable="true" data-visible='false'>A2</th>
                                        <th data-field="A3" data-sortable="true" data-visible='false'>A3</th>
                                        <th data-field="A4" data-sortable="true" data-visible='false'>A4</th>
                                        <th data-field="operate" data-sortable="true" data-events="actionEvents">Operate</th>
                                    </tr>
                                </thead>
                            </table>

I have tried lot of example and questions answers but none of them have solved my issue, Let me know if someone can help me for do it.我已经尝试了很多示例和问题的答案,但没有一个解决了我的问题,如果有人可以帮助我做到这一点,请告诉我。 Thanks!谢谢!

I assume you're using the actual product called 'Datatables' somehow.我假设您正在以某种方式使用名为“Datatables”的实际产品。 If so, then you need to add something to your export: exportOptions: { orthogonal: "dataExport" } You're not showing your javascript, and I've never seen all these options done in HTML.如果是这样,那么您需要在导出中添加一些内容:exportOptions:{正交:"dataExport" } 您没有显示您的 javascript,而且我从未见过所有这些选项都是在 HTML 中完成的。 Are you using some kind of framework, maybe Wordpress?你在使用某种框架,也许是 Wordpress? I don't use WP so I can't help you on how to do this in that product.我不使用 WP,因此我无法帮助您了解如何在该产品中执行此操作。 But just add 'orthogonal: "dataExport" ' to your 'data-export-options' thing.但只需将 'orthogonal: "dataExport" ' 添加到您的 'data-export-options' 内容中。 (you don't have to name it 'dataExport' -- I use that name because it's in some of the examples on the Datatables site). (您不必将其命名为“dataExport”——我使用该名称是因为它出现在 Datatables 站点上的一些示例中)。

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

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