Exportar dados através do Jasper Reports para xls, pdf e html. Exemplo:
Service service = new Service(new AutoReport());
Collection<Person> collection = asList(new Person("João", new Date()));
String path = "/people.pdf";// ou .xls, ou .html
service.export(collection, path);
No exemplo acima todas os atributos serão listados, para filtra-los é possível passar um Matcher.
Service service = new Service(new AutoReport(new Matcher<Field>() {
public boolean accepts(final Field element) {
return !field.getName().equals("abobora");
}
}));
Cabeçalho e rodapé podem ser personalizado sobreescrevendo os métodos header e footer da classe Report, parametro que é recebido no construtor de service.
Necessário adicionar os repositórios maven:
<repository>
<id>mvn-repo-releases</id>
<url>https://raw.github.com/clairton/mvn-repo/releases</url>
</repository>
<repository>
<id>mvn-repo-snapshot</id>
<url>https://raw.github.com/clairton/mvn-repo/snapshots</url>
</repository>
<repository>
<id>fdvsolution.public</id>
<url>http://archiva.fdvs.com.ar/repository/public1/</url>
</repository>
Também adicionar as depêndencias:
<dependency>
<groupId>br.eti.clairton</groupId>
<artifactId>exporter</artifactId>
<version>0.1.0</version>
</dependency>
<!--Libs externas usadas-->
<dependency>
<groupId>ar.com.fdvs</groupId>
<artifactId>DynamicJasper</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.12</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>net.vidageek</groupId>
<artifactId>mirror</artifactId>
<version>1.6.1</version>
</dependency>