Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: why the PageHeader still appear on first page?

  1. #1
    Join Date
    Mar 2003
    Posts
    27

    Default why the PageHeader still appear on first page?

    Why the pageHeader still appear on first after I setDispalyOnFirstPage(false);I use the 0.8.3c of the jfreereport.Thanks.

  2. #2
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    the page header should work perfectly. (and does for the current cvs version and version 0.8.3d). As there were no changes in that code since 0.8.3c, I assume that version is also ok.

    Could you please post your code so that I can have a look at this ...

    Have more fun,
    said Thomas

  3. #3
    Join Date
    Mar 2003
    Posts
    27

    Default Here is my code,Thanks.

    package ys;
    import com.jrefinery.report.*;
    import com.jrefinery.report.preview.*;
    import com.jrefinery.report.function.*;
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import javax.swing.*;
    import java.awt.geom.*;
    public class report extends JFreeReport{
    String id = "编号";
    String debh = "定额编号";
    String fxgc = "分项工程";
    String gcl = "工程量";
    String dw = "单位";
    String sbf = "主材费";
    String azf = "安装费";
    String clf = "材料费";
    String rgf = "人工费";
    String jjf = "机具费";


    private ResultSet getResultSet(){
    ResultSet rs = null;
    try{
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ys;user=sa;Password=");
    Statement st=conn.createStatement();
    String s="select * from de";
    rs=st.executeQuery(s);
    }catch(Exception ex){JOptionPane.showMessageDialog(null,"从数据库中获取数据错误,请检查数据源!");}
    return rs;
    }
    public report(){
    PageFormat pageFormat = new PageFormat();
    Paper paper = new Paper();
    paper.setSize(844,596);
    paper.setImageableArea(20,38,804,525);

    pageFormat.setPaper(paper);


    if(getResultSet()==null)return;
    try{
    com.jrefinery.report.tablemodel.ResultSetTableModelFactory rst;
    rst = com.jrefinery.report.tablemodel.ResultSetTableModelFactory.getInstance();
    com.jrefinery.report.util.CloseableTableModel model;
    model = rst.createTableModel(getResultSet());
    this.setData(model);
    this.setPageHeader(createPageHeader());
    this.setItemBand(createItemBand());
    this.setReportFooter(createReportFooter());
    this.setReportHeader(createReportHeader());
    this.setPageFooter(createPageFooter());
    }catch(Exception ex){}
    this.getDefaultPageFormat().setOrientation(PageFormat.LANDSCAPE);
    this.setDefaultPageFormat(pageFormat);

    }

    private PageHeader createPageHeader ()
    {

    PageHeader pageHeader = (PageHeader)
    ItemFactory.createPageHeader(60, new Font ("黑体", Font.PLAIN,12), null, false, true);


    Element ttile = ItemFactory.createLabelElement("title",new Rectangle2D.Float(0,0,804,30),null,
    Element.CENTER,new Font("黑体",Font.PLAIN,18),"川 橡 集 团 装 备 部 工 程 预 算 书");
    pageHeader.addElement(ttile);
    Element eid = ItemFactory.createLabelElement("mid",new Rectangle2D.Float(0,42,30,20)
    ,null,Element.CENTER,null,id);
    Element l1 = ItemFactory.createLabelElement("l1",new Rectangle2D.Float(400,32,80,20)
    ,null,Element.CENTER,null,"单 价");
    Element l2 = ItemFactory.createLabelElement("l2",new Rectangle2D.Float(600,32,80,20)
    ,null,Element.CENTER,null,"总 价");
    Element edebh = ItemFactory.createLabelElement("mdebh",new Rectangle2D.Float(30,42,50,20)
    ,null,Element.CENTER,null,debh);
    Element efxgc = ItemFactory.createLabelElement("mfxgc",new Rectangle2D.Float(80,42,110,20)
    ,null,Element.CENTER,null,fxgc);
    Element egcl = ItemFactory.createLabelElement("mgcl",new Rectangle2D.Float(190,42,55,20)
    ,null,Element.CENTER,null,gcl);
    Element edw = ItemFactory.createLabelElement("mdw",new Rectangle2D.Float(245,42,60,20)
    ,null,Element.CENTER,null,dw);
    Element esbf = ItemFactory.createLabelElement("msbf",new Rectangle2D.Float(305,48,50,20)
    ,null,Element.CENTER,null,sbf);
    Element eazf = ItemFactory.createLabelElement("mazf",new Rectangle2D.Float(355,48,50,20)
    ,null,Element.CENTER,null,azf);
    Element ergf = ItemFactory.createLabelElement("mrgf",new Rectangle2D.Float(405,48,50,20)
    ,null,Element.CENTER,null,rgf);
    Element eclf = ItemFactory.createLabelElement("mclf",new Rectangle2D.Float(455,48,50,20)
    ,null,Element.CENTER,null,clf);
    Element ejjf = ItemFactory.createLabelElement("mjjf",new Rectangle2D.Float(505,48,50,20)
    ,null,Element.CENTER,null,jjf);
    Element eesbf = ItemFactory.createLabelElement("mssbf",new Rectangle2D.Float(555,48,50,20)
    ,null,Element.CENTER,null,sbf);
    Element eeazf = ItemFactory.createLabelElement("msazf",new Rectangle2D.Float(605,48,50,20)
    ,null,Element.CENTER,null,azf);
    Element eergf = ItemFactory.createLabelElement("msrgf",new Rectangle2D.Float(655,48,50,20)
    ,null,Element.CENTER,null,rgf);
    Element eeclf = ItemFactory.createLabelElement("msclf",new Rectangle2D.Float(705,48,50,20)
    ,null,Element.CENTER,null,clf);
    Element eejjf = ItemFactory.createLabelElement("msjjf",new Rectangle2D.Float(755,48,50,20)
    ,null,Element.CENTER,null,jjf);

    pageHeader.addElement(l1);
    pageHeader.addElement(l2);
    pageHeader.addElement(eid);
    pageHeader.addElement(edebh);
    pageHeader.addElement(efxgc);
    pageHeader.addElement(egcl);
    pageHeader.addElement(edw);
    pageHeader.addElement(esbf);
    pageHeader.addElement(eazf);
    pageHeader.addElement(ergf);
    pageHeader.addElement(eclf);
    pageHeader.addElement(ejjf);
    pageHeader.addElement(eesbf);
    pageHeader.addElement(eeazf);
    pageHeader.addElement(eergf);
    pageHeader.addElement(eeclf);
    pageHeader.addElement(eejjf);


    pageHeader.addElement (
    ItemFactory.createLineShapeElement (
    "line1",
    Color.decode ("#CFCFCF"),
    new BasicStroke (2),
    new Line2D.Float (0, 30, 0, 30)
    )
    );

    pageHeader.addElement (
    ItemFactory.createLineShapeElement (
    "line1",
    Color.decode ("#CFCFCF"),
    new BasicStroke (2),
    new Line2D.Float (30, 60,30, 60)
    )
    );

    pageHeader.addElement (
    ItemFactory.createLineShapeElement (
    "line1",
    Color.decode ("#CFCFCF"),
    new BasicStroke (0.5f),
    new Line2D.Float (305, 46, 804, 46)
    )
    );

    pageHeader.addElement(ItemFactory.createLineShapeElement("li",Color.decode("#CFCFCF"),new BasicStroke(1),
    new Line2D.Float(0,30,0,68)));
    pageHeader.addElement(ItemFactory.createLineShapeElement("as",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(30,30,30,68)));
    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(804,30,804,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(755,46,755,68)));


    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(705,46,705,68)));


    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(655,46,655,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(605,46,605,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(555,30,555,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(505,46,505,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(455,46,455,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(405,46,405,68)));
    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(355,46,355,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(305,30,305,68)));

    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(245,30,245,68)));


    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(190,30,190,68)));


    pageHeader.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(80,30,80,68)));


    return pageHeader;
    }

    private ItemBand createItemBand ()
    {
    ItemBand items = (ItemBand)
    ItemFactory.createItemBand (18, new Font ("黑体", Font.PLAIN, 12), Color.black);



    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(804,0,804,18)));


    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(755,0,755,18)));

    items.addElement(ItemFactory.createLineShapeElement("dad",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(705,0,705,18)));



    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(655,0,655,18)));


    items.addElement (
    ItemFactory.createLineShapeElement (
    "bottom",
    Color.decode ("#CFCFCF"),
    new BasicStroke (0.1f),
    new Line2D.Float (0, 17, 0, 17)
    )
    );

    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(605,0,605,18)));


    items.addElement(ItemFactory.createLineShapeElement("dk",Color.decode("#CFCFCF"),
    new BasicStroke(1),new Line2D.Float(0,0,0,18)));
    items.addElement(ItemFactory.createLineShapeElement("dk",Color.decode("#CFCFCF"),
    new BasicStroke(0.2f),new Line2D.Float(30,0,30,18)));


    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(555,0,555,18)));

    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(505,0,505,18)));

    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(455,0,455,18)));

    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(405,0,405,18)));
    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(355,0,355,18)));

    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(305,0,305,18)));

    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(245,0,245,18)));


    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(190,0,190,18)));


    items.addElement(ItemFactory.createLineShapeElement("da",Color.decode("#CFCFCF"),new BasicStroke(0.2f),
    new Line2D.Float(80,0,80,18)));



    items.addElement (
    ItemFactory.createStringElement (
    "myid",
    new Rectangle2D.Float (0,0,30,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "id"
    )
    );

    items.addElement (
    ItemFactory.createStringElement (
    "mydebh",
    new Rectangle2D.Float (30,0,50,17),
    null,
    Element.LEFT, Element.MIDDLE,
    null,
    "<null>",
    "debh"
    )
    );
    items.addElement (
    ItemFactory.createStringElement (
    "myfxgc",
    new Rectangle2D.Float (80,0,110,17),
    null,
    Element.LEFT, Element.MIDDLE,
    null,
    "<null>",
    "fxgc"
    )
    );
    items.addElement (
    ItemFactory.createNumberElement (
    "mygcl",
    new Rectangle2D.Float (190,0,35,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "gcl"
    )
    );

    items.addElement (
    ItemFactory.createStringElement (
    "mydw",
    new Rectangle2D.Float (245,0,55,17),
    null,
    Element.LEFT, Element.MIDDLE,
    null,
    "0",
    "dw"
    )
    );

    items.addElement (
    ItemFactory.createNumberElement (
    "mysbf",
    new Rectangle2D.Float (305,0,40,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "sbf"
    )
    );
    Element azf = ItemFactory.createNumberElement("azf",
    new Rectangle2D.Float (355,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "azf"
    );
    items.addElement (
    azf);

    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (405,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "rgf"
    )
    );



    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (455,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "clf"
    )
    );

    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (505,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "jjf"
    )
    );
    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (555,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "rsbf"
    )
    );

    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (605,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "razf"
    )
    );

    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (655,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "rrgf"
    )
    );

    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (705,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "rclf"
    )
    );
    items.addElement (
    ItemFactory.createNumberElement (
    "Population Element",
    new Rectangle2D.Float (755,0,50,17),
    null,
    Element.CENTER, Element.MIDDLE,
    null,
    "0",
    "0.00",
    "rjjf"
    )
    );



    return items;
    }

    private PageFooter createPageFooter(){
    PageFooter pageFooter = (PageFooter)ItemFactory.createPageFooter(18,new Font("黑体",Font.PLAIN,12),null,true,true);
    pageFooter.setDisplayOnFirstPage(true);
    return pageFooter;
    }
    private ReportFooter createReportFooter(){
    ReportFooter reportFooter = (ReportFooter)ItemFactory.createReportFooter(20,new Font("黑体",Font.PLAIN,12),null,true);

    return reportFooter;
    }
    private ReportHeader createReportHeader(){
    ReportHeader reportHeader = (ReportHeader)ItemFactory.createReportHeader(600,new Font("黑体",Font.PLAIN,12),null,true);
    Element edebh = ItemFactory.createLabelElement("mdebh",new Rectangle2D.Float(30,100,50,20)
    ,null,Element.CENTER,null,debh);
    reportHeader.addElement(edebh);

    return reportHeader;
    }

    public static void main(String[] args){
    try{
    report rp = new report();
    com.jrefinery.report.preview.PreviewFrame pf = new com.jrefinery.report.preview.PreviewFrame(rp);
    pf.setVisible(true);
    pf.setSize(Toolkit.getDefaultToolkit().getScreenSize());
    }catch(Exception ex){}
    }

    }

  4. #4
    Join Date
    Mar 2003
    Posts
    27

    Default I have already solved the problem,Tanks a lot.

    I have already solved the problem,Tanks a lot.

  5. #5
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    this report does not work. You defined your report page size to have a maximum height of 594 points, but your report header has a minimum height of 600 points.

    As you also want to print the page footer on the first page, your imageable page size must be at least 618 points.

    When I increase the page size to 694 and the imageabe height to 625, everything is working fine and the page header appears on the second page (but not on the first).

    So I can't see any problem with JFreeReport here, just problems with the report definition.
    Once these are resolved, your report should work perfectly.

    Btw. If you want to print the report header on its own page, it is totally sufficient to set the corresponding pagebreak flag to true, and regardless how large the header is, you get your pagebreak after the header was printed.

    You can safely reduce the report header height to lower values, without affecting the report layout. This should also fix the problems with the report-does-not-proceed messages as this will guarantee, that the report header will fit on the page.

    Have more fun,
    said Thomas

  6. #6
    Join Date
    Mar 2003
    Posts
    27

    Default Thanks.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.