I have a need to generate an excel sheet report which looks like the following template --
我需要生成一个类似于以下模板的excel表格报告
I know this can be done using libraries like JExcelApi
and Apache POI
. However I would like to know if there are means of accomplishing this by writing a template similar to writing Apache Velocity
templates for sending emails.
我知道这可以通过使用JExcelApi和Apache POI之类的库来实现。但是,我想知道是否有方法通过编写一个类似于为发送电子邮件编写Apache Velocity模板的模板来实现这一点。
If there is a standard, good-practice approach for generating such reports what is it?
如果有一种标准的、良好的方法来生成这样的报告,那是什么呢?
2 个解决方案
#1
7
Why not create a styled template using Excel? Use placeholders (like ${name.of.field}) for the values that should be substituted, but otherwise style everything as required. Use a different placeholder to mark the end-of-template (this will allow you to write comments or other data beyond this space, to document your template).
为什么不使用Excel创建一个样式模板呢?使用占位符(如${name.of.field})替换应该替换的值,但在其他情况下按需要样式化所有值。使用不同的占位符来标记模板的结束(这将允许您编写注释或其他超出此空间的数据,以记录模板)。
Then, either via JExcelApi or Apache POI,
然后,通过JExcelApi或Apache POI,
- open the template file, and locate the end-of-template marker.
- 打开模板文件,并找到模板结束标记。
- open the target file
- 打开目标文件
- for each record, copy fields from the template, substituting ${xyz}-values for their actual contents and stopping once you reach your end-of-template marker.
- 对于每条记录,从模板中复制字段,用${xyz}值替换它们的实际内容,并在到达模板结束标记后停止。
- close target & template
- 接近目标&模板
Template modification will be extremely easy. The only problem is keeping the field-names in sync.
模板修改非常简单。唯一的问题是保持字段名的同步。
#2
1
You can use a standard Java reporting library like i-net Clear Reports and use the excel output format.
您可以使用标准的Java报表库,如i-net Clear Reports,并使用excel输出格式。
#1
7
Why not create a styled template using Excel? Use placeholders (like ${name.of.field}) for the values that should be substituted, but otherwise style everything as required. Use a different placeholder to mark the end-of-template (this will allow you to write comments or other data beyond this space, to document your template).
为什么不使用Excel创建一个样式模板呢?使用占位符(如${name.of.field})替换应该替换的值,但在其他情况下按需要样式化所有值。使用不同的占位符来标记模板的结束(这将允许您编写注释或其他超出此空间的数据,以记录模板)。
Then, either via JExcelApi or Apache POI,
然后,通过JExcelApi或Apache POI,
- open the template file, and locate the end-of-template marker.
- 打开模板文件,并找到模板结束标记。
- open the target file
- 打开目标文件
- for each record, copy fields from the template, substituting ${xyz}-values for their actual contents and stopping once you reach your end-of-template marker.
- 对于每条记录,从模板中复制字段,用${xyz}值替换它们的实际内容,并在到达模板结束标记后停止。
- close target & template
- 接近目标&模板
Template modification will be extremely easy. The only problem is keeping the field-names in sync.
模板修改非常简单。唯一的问题是保持字段名的同步。
#2
1
You can use a standard Java reporting library like i-net Clear Reports and use the excel output format.
您可以使用标准的Java报表库,如i-net Clear Reports,并使用excel输出格式。