dynamicreports1

转载 2016年08月28日 19:26:13
package report;

import static net.sf.dynamicreports.report.builder.DynamicReports.cmp;
import static net.sf.dynamicreports.report.builder.DynamicReports.col;
import static net.sf.dynamicreports.report.builder.DynamicReports.exp;
import static net.sf.dynamicreports.report.builder.DynamicReports.grid;
import static net.sf.dynamicreports.report.builder.DynamicReports.report;
import static net.sf.dynamicreports.report.builder.DynamicReports.sbt;
import static net.sf.dynamicreports.report.builder.DynamicReports.stl;
import static net.sf.dynamicreports.report.builder.DynamicReports.type;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import net.sf.dynamicreports.adhoc.AdhocManager;
import net.sf.dynamicreports.adhoc.configuration.AdhocColumn;
import net.sf.dynamicreports.adhoc.configuration.AdhocConfiguration;
import net.sf.dynamicreports.adhoc.configuration.AdhocReport;
import net.sf.dynamicreports.examples.Templates;
import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import net.sf.dynamicreports.report.base.expression.AbstractSimpleExpression;
import net.sf.dynamicreports.report.builder.column.ColumnBuilder;
import net.sf.dynamicreports.report.builder.column.TextColumnBuilder;
import net.sf.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder;
import net.sf.dynamicreports.report.builder.style.StyleBuilder;
import net.sf.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder;
import net.sf.dynamicreports.report.constant.HorizontalAlignment;
import net.sf.dynamicreports.report.datasource.DRDataSource;
import net.sf.dynamicreports.report.definition.ReportParameters;
import net.sf.dynamicreports.report.exception.DRException;
import net.sf.jasperreports.engine.JRDataSource;

    

    /**

     * @author Ricardo Mariaca (r.mariaca@dynamicreports.org)

     */

    public class Invoicetest {

       private InvoiceData data = new InvoiceData();

       private AggregationSubtotalBuilder<BigDecimal> totalSum;

       private JRDataSource createDataSource1() {
           
           DRDataSource dataSource = new DRDataSource("item", "quantity", "unitprice", "quantity1", "unitprice1", "quantity2", "unitprice2", "quantity3");
 
       //    dataSource.add("Notebook", 1, new BigDecimal(500));
 
        dataSource.add(null,null , null,null , null,null , null);
           return dataSource;
 
        }
       
       private JRDataSource createDataSource() {

              DRDataSource dataSource = new DRDataSource("item", "orderdate", "quantity");

              for (int i = 0; i < 20; i++) {

                 dataSource.add("Book", new Date(), (int) (Math.random() * 10) + 1);

              }

              return dataSource;

           }

       public JasperReportBuilder build() throws DRException {
           JasperReportBuilder report5 = report();
           try {
               TextColumnBuilder<String>[] columns = new TextColumnBuilder[7];
               columns[0] =  col.column("Totle",       "item",      type.stringType()).setWidth(200);
               columns[1] =  col.column("Totle1",       "item1",      type.stringType());
               columns[2] =  col.column("Totle2",       "item2",      type.stringType());
               columns[3] =  col.column("Totle3",       "item3",      type.stringType());
               columns[4] =  col.column("Totle4",       "item4",      type.stringType());
               columns[5] =  col.column("Totle5",       "item5",      type.stringType());
               columns[6] =  col.column("Totle6",       "item6",      type.stringType());
            //   columns[7] =  col.column("Totle7",       "item7",      type.stringType());
               
               StyleBuilder columnStyle = stl.style(Templates.columnStyle)

                 .setBorder(stl.pen1Point());

              StyleBuilder subtotalStyle = stl.style(columnStyle)

                 .bold();

              StyleBuilder shippingStyle = stl.style(Templates.boldStyle)

                 .setHorizontalAlignment(HorizontalAlignment.RIGHT);
              
               report5 =  report()//create new report design
               .setTemplate(Templates.reportTemplate)

          //   .setColumnStyle(columnStyle)

         //    .setSubtotalStyle(subtotalStyle)
                              .columns(//add columns
                                      columns)
                          
                              .setDataSource(createDataSource1());//set datasource
               
                         //     .show();//create and show report
               
                         } catch (Exception e) {
               
                            e.printStackTrace();
               
                         }
           
            String titlev = "test title";

          JasperReportBuilder report = report();

         

          //init styles

          StyleBuilder columnStyle = stl.style(Templates.columnStyle)

             .setBorder(stl.pen1Point());

          StyleBuilder subtotalStyle = stl.style(columnStyle)

             .bold();

          StyleBuilder shippingStyle = stl.style(Templates.boldStyle)

             .setHorizontalAlignment(HorizontalAlignment.RIGHT);

    

          //init columns

          TextColumnBuilder<Integer> rowNumberColumn = col.reportRowNumberColumn()

             .setFixedColumns(2)

             .setHorizontalAlignment(HorizontalAlignment.CENTER);

//          TextColumnBuilder<String> descriptionColumn = col.column("Description", "description", type.stringType())
//
//             .setFixedWidth(250);
         
          TextColumnBuilder<Integer> quantityColumn = col.column("Quantity", "quantity", type.integerType()).setWidth(100)

             .setHorizontalAlignment(HorizontalAlignment.CENTER);

          TextColumnBuilder<BigDecimal> unitPriceColumn = col.column("Unit Price", "unitprice", Templates.currencyType).setWidth(100);

          
          TextColumnBuilder<String> colaa = col.column("Unit Price", "description1", type.stringType());
          TextColumnBuilder<String> colbb = col.column("Unit Price", "description2", type.stringType());

          TextColumnBuilder<String> colaa1 = col.column("Unit Price", "description1", type.stringType());
          TextColumnBuilder<String> colbb1 = col.column("Unit Price", "description2", type.stringType());

          TextColumnBuilder<String> colaa2 = col.column("Unit Price", "description1", type.stringType());
          TextColumnBuilder<String> colbb2 = col.column("Unit Price", "description2", type.stringType());

          
          TextColumnBuilder<String> priceColumn = colaa

                  .setTitle("Price")

                  .setDataType(type.stringType());

               //vat = price * tax
          TextColumnBuilder<String> priceColumn2 = colbb

                  .setTitle("Price1")

                  .setDataType(type.stringType());
              
          TextColumnBuilder<String> priceColumna = colaa1

                  .setTitle("aPrice")

                  .setDataType(type.stringType());

               //vat = price * tax
          TextColumnBuilder<String> priceColumn2a = colbb1

                  .setTitle("aPrice1")

                  .setDataType(type.stringType());
          
          TextColumnBuilder<String> priceColumnb = colaa2

                  .setTitle("bPrice")

                  .setDataType(type.stringType());

               //vat = price * tax
          TextColumnBuilder<String> priceColumn2b = colbb2

                  .setTitle("bPrice1")

                  .setDataType(type.stringType());
     
          //total = price + vat
          ColumnTitleGroupBuilder totalColumn = grid.titleGroup("Total Price 1", priceColumn, priceColumn2);
          ColumnTitleGroupBuilder totalColumn1 = grid.titleGroup("Total Price 2", priceColumna, priceColumn2a);
          ColumnTitleGroupBuilder totalColumn2 = grid.titleGroup("Total Price 3", priceColumnb, priceColumn2b);
          
          
          report

             .setTemplate(Templates.reportTemplate)

             .setColumnStyle(columnStyle)

             .setSubtotalStyle(subtotalStyle)

               .columnGrid(
                      quantityColumn, unitPriceColumn, totalColumn,totalColumn1,totalColumn2)
               .columns(
                       quantityColumn, unitPriceColumn,priceColumn, priceColumn2,priceColumna, priceColumn2a,priceColumnb, priceColumn2b)
              
                        .summary(cmp.subreport(report5))
                       .pageFooter(

                Templates.footerComponent)

             .setDataSource(createInvoice());

          return report;

       }

       private class TotalPaymentExpression extends AbstractSimpleExpression<String> {

          private static final long serialVersionUID = 1L;

    

          @Override

          public String evaluate(ReportParameters reportParameters) {

return null;
          }

       }

    

       public static void main(String[] args) {

           Invoicetest design = new Invoicetest();

          try {

             JasperReportBuilder report = design.build();

             report.show();

          } catch (DRException e) {

             e.printStackTrace();

          }

       }
       private List<Item> createInvoice() {
           List<Item> items = new ArrayList<Item>();
           items.add(createItem("Notebook", 1, new BigDecimal(1000)));
           items.add(createItem("DVD", 5, new BigDecimal(40)));
           items.add(createItem("Book", 2, new BigDecimal(10)));
           items.add(createItem("Phone", 1, new BigDecimal(200)));
           
           return items;
       }
       
       private Item createItem(String description, Integer quantity, BigDecimal unitprice) {
           Item item = new Item();
           item.setDescription(description);
           item.setQuantity(quantity);
           item.setUnitprice(unitprice);
           item.setDescription1("aaa");
           item.setDescription2("bbb");
           return item;
       }
    }

相关文章推荐

dynamicreports demo

  • 2015-04-23 12:02
  • 22.92MB
  • 下载

纯JAVA代码利用DynamicReports插件生成动态报表

1.首先,我的目的是纯java项目连接SQL2008数据库,之后能够应客户需要打印出用户的近期10次的消费回单。 2.昨天想到用ireport+jasperreports生成报表,发现生成的是静态...

dynamicreports

  • 2015-01-11 01:16
  • 41.43MB
  • 下载

SQLyog-9.1.0-1及注册机

  • 3天前 20:29
  • 15.12MB
  • 下载

1小时学会Shell基础

1小时学会Shell基础

我的App全栈之路(1)环境的搭建

从2015年毕业到现在一直从事的是安卓手机应用的开发,在这之前一直没有尝试过后台,所以抽出一些时间尝试一次相当于全站的历程. 我会一步步记录我从零开始到实现一个完整的APP前端和后台的过程. 鄙人也是...

icu4c-4_2_1-src(icu4c库)

  • 2017-10-13 11:45
  • 12.55MB
  • 下载

eclipse安卓开发真机连接1

  • 2017-10-12 14:41
  • 538KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)