新建Export2ExcelCommand命令控件
在commandExecute的【Controls】节点下新建Export2ExcelCommand控件。步骤:【Controls】—>【Insert】—>【Commands】—>【Export2ExcelCommand】。
图15-62
设置新建Export2ExcelCommand控件命名cmd2Excel,绑定datasetEmployee,设置导出模板属性templateTable的值为tableEmployee。同时,设置dataMode的属性值为client-visible,设置exportMode的属性值为output。
图15-63
新建Button按钮命名btnExcel,设置绑定cmd2Excel控件,设置value值为"导出到Excel"。添加btnExcel按钮至command_execute.jsp中,刷新页面查看效果。
图15-64
点击【导出到Excel】按钮,查看数据导出到Excel中的效果。
图15-65
dataMode和exportMode
在Export2ExcelCommand命令控件中有一些属性控制数据导出至Excel时的不同模式,这里主要介绍dataMode数据模式和exportMode导出模式。
- dataMode
该属性主要设置导出的数据范围。主要属性值有server-all、server-current-page、client-visible、client-selected四种。
-
- server-all
绑定的Dataset数据集对象中来自服务器端的全部数据。即忽略当前客户端的Dataset是否是分页数据而重新从服务器端获取全部的未分页的数据。(大数据量时慎用)
-
- server-current-page
绑定的Dataset数据集对象中来自服务器端的当前页数据。即忽略当前客户端的Dataset中被删除或者被过滤的记录对象,重新从服务器端加载当前页记录集导出至Excel。
-
- client-visible
绑定的Dataset数据集对象中客户端的所有可见记录。即排除已经被删除及被过滤的其他所有记录对象。
-
- client-selected
绑定的Dataset数据集对象中客户端的所有被勾选的记录对象。即select字段的值为true的所有记录对象。
- exportMode
该属性主要设置导出到Excel中的导出模式。主要属性值有output、download两种。
-
- output
该属性值意味着导出至Excel后直接在当前浏览器中打开查看。
-
- download
该属性值意味着导出至Excel后需要按照文件下载的方式下载到客户端生成后缀名为.xls的文件打开查看。
开发步骤
Export2ExcelCommand支持将Dataset数据集导出至Excel中展现,通过指定dataMode和exportMode属性,可以实现多种模式的导出。
|
|
|
|
|
|
|
|
|
|
|
|
Attachments:








