- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我使用的是 primefaces 3.5,我有一个包含一些行和数据的 p:dataTable,我想将这些数据导出到 xls 文件或其他文件中。
我使用了代码:
<p:commandButton id="exportBtn" icon="ui-icon-extlink" styleClass="statisticsMenuButton" ajax="false" title="#{msg.general_export_as_xls}">
<p:dataExporter type="xls" target="cc-eventListTable-eventList" fileName="statistics"/>
</p:commandButton>
这很好用!
我的问题是,我希望在导出的文件和浏览器数据表中有不同的单元格文本。
例如,在导出的 xls 文件中,我需要在浏览器数据表中设置其他日期格式。否则浏览器单元格中的文本太长了!
我试图为导出的表添加一个额外的列,其中 rendered="false"和 exportable="true"。但不幸的是它不起作用!
有人知道怎么做吗?
最佳答案
将呈现的标签设置为 false 它目前不起作用(它被报告为错误:https://github.com/primefaces-extensions/primefaces-extensions.github.com/issues/209),但你可以像这样使用 css 来实现它:
<p:column headerText="#{msg['book.coverType']}" style="display:none;">
<h:outputText value="#{book.coverType}"/>
</p:column>
另一种解决方案是在托管 bean 中添加一个后处理方法并从那里添加列。
public void postProcessXLS(对象文档){ log.debug("后期处理Excel");
HSSFWorkbook workbook = (HSSFWorkbook) document;
addCoverType(workbook,book);
}
你可以这样写方法:
public void addCoverType(HSSFWorkbook workbook, List<Book> books) {
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFCell cell = null;
//row 0 is the header (not automatically added by primefaces)
//add a fifth cell to each row
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
sheet.getRow(i).createCell(4);
cell = sheet.getRow(i).getCell(4);
cell.setCellValue(book.get(i - 1).getCoverType());
}
log.debug("cover type added");
}
如果您制作可排序列,顺序也会自动得到遵守:-D
关于java - Primefaces 3.5 如何使用 dataExporter 导出不可见的 dataTable 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21047859/
该插件的绝大多数文档表明您可以使用 对其进行初始化 $('#example').dataTable(); 但是http://www.datatables.net/examples/api/multi_
我有一个 SQL 查询,它获取一些数据(dbtable 表中的语言列)。查询使用 GROUP_CONCAT,因此一个单元格有多个结果,例如 "Ajax, jQuery, HTML, CSS". 我想要
我有一个由 jQuery DataTables 增强的动态表,它显示一个与此类似的自定义对象 example . JSON: { "data": [ { "name": "Ti
我有两个数据表。首先是 DataTable NameAddressPhones = new DataTable(); 具有三列姓名、地址和电话号码。但我只想要两列姓名和地址数据,所以我想将这些列(包含
有没有办法将“处理...”语言放在 DataTable 对象的顶部而不是垂直中间?如果我有一张长 table ,它会隐藏在页面之外,因为它的默认位置在中间。 $('#example').dataTab
当我们向 DataTables 添加自定义过滤器时: $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { ..
我可以更改 dataTables 中搜索文本字段的宽度吗? 我现在正在编写以下代码,但它不起作用。 $('#example').dataTable() .columnFilter(
使用 DataTables plugin 时 如何使分页和 Showing 1 to 8 of 8 entries 出现在顶部而不是底部? 谢谢 最佳答案 每个数据表控件都以唯一的 id 命名计划之后
Angular 版本:6.0.4 ~ 节点版本:10.4.1 ~ NPM 版本:6.1.0 我看到这个问题被问了很多次,但没有回答。 关注这些后instructions to install angu
当单击外部按钮时,我正在尝试使用 DataTable(新版本)修改单元格值。我现在有以下内容: $(document).on('click', '.dropdown-menu li a', funct
引用:http://datatables.net/reference/api/page.info() 我正在尝试获取 ajax POST 生成的 jQuery DataTable 的当前分页信息。 使
以下对我有用: $('#datatable').on('page.dt', function() { alert("changed"); }); 每当我更改页面时,都会显示警报。但是如果我想警
我有一个 HTML 表,我在其中应用了 DataTables 函数。我使用表的第一行并将"template"类应用为我的模板行。然后选择此格式并使用 JSON feed 填充表中的所有行。问题是 Da
我有一个由 DataTables 1.10 驱动的表。过滤已打开。当我在下面谈论“做搜索”时,我指的是使用该表的过滤功能。 问题描述 关闭 stateSave 一切正常。但是,当 stateSave
看看这个例子,http://www.datatables.net/examples/api/multi_filter_select.html ,它使用 DataTable API 中的 columns
我正在使用 jQuery DataTables 在 spring 4.x 应用程序中创建一个报表页面来呈现报表。 通过 Jackson 消息转换器解析后,服务器返回以下对象。 { "data"
我在刷新 Primesfaces 的延迟加载数据表时遇到了一些问题。我正在使用 3.0.M4。 使用过滤器在您的示例中使用三个类。还尝试了仅使用延迟加载的示例,但随后未在 Controller 中重新
在 Blue Prism (BP) 中,有一种叫做 Collection 的东西,它基本上是 C# 中的 DataTable。在 BP 中,您可以在集合中拥有集合。我的问题是,您可以在 C# 的 Da
我正在使用 Flutter DataTables 来显示购物车中的商品列表。现在我想编辑任何选定行的数量。有没有办法获取用户点击的行信息? 以下是我的DataTable的完整代码: class _Da
我有一个关于 primefaces 数据表组件的问题。我想将 DataTable 变量绑定(bind)到 p:dataTable,以便我能够从支持 bean 以编程方式操作第一个、行、rowsPerP
我是一名优秀的程序员,十分优秀!