问题描述
我正在使用 JXLS 填充模板 Excel 电子表格.有时,一个输入——一个列表——是空的.发生这种情况时,使用此列表的模板字段将以完整的 JXLS regalia 显示在填充的电子表格中 - 例如,${someList.someValue}
".
I'm using JXLS to populate a template excel spreadsheet. Sometimes, one input - a list - is empty. When this happens, the template fields which use this list are shown in the populated spreadsheet in full JXLS regalia - eg, "${someList.someValue}
".
有问题的字段都在一行中(由 JXLS 扩展为 list.size()
行).当列表中没有记录时,我想清除整行.
The fields in question are all in a single row (expanded to list.size()
rows by JXLS). I want to clear the whole row when there are no records in the list.
在 JXLS 中有没有办法做到这一点?或者,有人可以建议使用 JExcel 或 POI 的补充方法吗?
Is there a way to do so in JXLS? Alternatively, can anyone suggest a complementary way to use JExcel or POI to do so?
推荐答案
您可以使用 <jx:if>excel 模板中的标签.例如,如果您有一个类似于以下内容的模板
You can use <jx:if> tags in your excel template.For example if you have a template similar to the following
Row 1: <jx:if test="${!empty someData}">
Row 2: place holders for data that will be printed in the loop
Row 3: </jx:if>
如果 someData 不为空,则输出中将打印行,但如果 someData 为空,则此模板将不打印任何行.
If someData is not empty then rows will be printed in the output but if someData is empty then no rows will be printed by this template.
我希望我能说清楚.请参阅 http://jxls.sourceforge.net/reference/tags.html 了解更多关于标签的信息.
I hope I could make it clear. Please see http://jxls.sourceforge.net/reference/tags.html for more information about tags.
这篇关于当输入列表为空时删除 JXLS 中的模板行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!