1.easyui datagrid 有个方法getRows 获取到当前datagrid 显示的所有数据

2.通过json2.js 中的方法把datagrid 数据转换成json字符串,json2.js的源码地址:
https://github.com/douglascrockford/JSON-js

3.之前想通过JQuery ajax函数下载服务端动态生成的excel文件,后来发现ajax函数的返回类型只有xml、text、json、html等类型,没有“流”类型,所以要实现ajax下载,不能够使用相应的ajax函数进行文件下载。但可以用js生成一个form,用这个form提交参数,并返回“流”类型的数据。在实现过程中,页面也没有进行刷新。

4.服务端获取form表单提交的数据,字符串反序列化变成对象,这里用到Gson,然后使用easypoi动态生成excel(这里吐槽一下easypoi的官方文档好少),再使用流的方式把生成的excel返回到前台。

网友评论