1 package ar.com.fdvs.dj.test;
2
3 import java.util.Date;
4
5 import ar.com.fdvs.dj.core.layout.LayoutManager;
6 import ar.com.fdvs.dj.core.layout.ListLayoutManager;
7 import ar.com.fdvs.dj.domain.DynamicReport;
8 import ar.com.fdvs.dj.domain.Style;
9 import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
10 import ar.com.fdvs.dj.domain.constants.GroupLayout;
11 import ar.com.fdvs.dj.domain.entities.DJGroup;
12
13 public class XlsReportTest extends BaseDjReportTest {
14
15 public DynamicReport buildReport() throws Exception {
16
17
18 /***
19 * Creates the DynamicReportBuilder and sets the basic options for
20 * the report
21 */
22 FastReportBuilder drb = new FastReportBuilder();
23 Style columDetail = new Style();
24
25
26 drb.addColumn("State" , "state" , String.class.getName(), 30)
27 .addColumn("Branch" , "branch" , String.class.getName(), 30)
28 .addColumn("Product Line" , "productLine" , String.class.getName(), 50)
29
30
31
32 .addColumn("Amount" , "amount" , Float.class.getName() , 70, true)
33 .addColumn("Date" , "date" , Date.class.getName() , 70, true, "dd/MM/yyyy",null)
34 .addGroups(2)
35 .setPrintColumnNames(true)
36 .setIgnorePagination(true)
37 .setMargins(0, 0, 0, 0)
38 .setTitle("November 2006 sales report")
39 .setSubtitle("This report was generated at " + new Date())
40 .setReportName("My Excel Report")
41 .setDefaultStyles(null, null, null, columDetail)
42 .setUseFullPageWidth(true);
43
44 DynamicReport dr = drb.build();
45
46 DJGroup group = (DJGroup) dr.getColumnsGroups().iterator().next();
47 group.setLayout(GroupLayout.EMPTY);
48
49 return dr;
50 }
51
52 protected LayoutManager getLayoutManager() {
53 return new ListLayoutManager();
54 }
55
56 protected void exportReport() throws Exception {
57 ReportExporter.exportReportXls(jp, System.getProperty("user.dir")+ "/target/" + this.getClass().getName() + ".xls");
58 }
59
60
61 public static void main(String[] args) throws Exception {
62 XlsReportTest test = new XlsReportTest();
63 test.testReport();
64 }
65 }