最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Server side excel export with DataTable - Stack Overflow

programmeradmin0浏览0评论

I have a DataTables with server side processing. On server side I have functions retrieving filters from the ajax request and fetching data from database.

Now I want export data into excel file with filters.

I assume I have to design an excel file creator on server side and send the file through HTTP response.

I would like use already-defined functions to handle export request.

My question is: how can I send DataTables filter as same format as in the ajax request to my server ?

I have a DataTables with server side processing. On server side I have functions retrieving filters from the ajax request and fetching data from database.

Now I want export data into excel file with filters.

I assume I have to design an excel file creator on server side and send the file through HTTP response.

I would like use already-defined functions to handle export request.

My question is: how can I send DataTables filter as same format as in the ajax request to my server ?

Share Improve this question asked Aug 14, 2015 at 15:36 ZxcvZxcv 1,7472 gold badges16 silver badges23 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 6

SOLUTION

You can use ajax.params() to get the data submitted by DataTables to the server in the last Ajax request.

Then you can redirect to script that generates Excel file with these parameters using jQuery helper function $.param that converts array into query string.

For example:

window.location = '/getFile.php?' + $.param($('#example').DataTable().ajax.params());

where example is table ID.

NOTES

There is also TableTools extension with Download button but with recent jQuery DataTables 1.10.8 release, TableTools extension is now deprecated.

发布评论

评论列表(0)

  1. 暂无评论