簡體   English   中英

jasper 報告打印不正確

[英]jasper report is not printing properly

我正在使用 jasper 報告打印,我使用 netbeans 的 ireport 插件創建了報告,所以當我看到預覽看起來不錯,但是當我打印數據時,它的格式不正確,只有標題帶出現在打印頁面下面是我的代碼

     void showResports(){
    try{
      // OriginalExportOriginalExport 
         String reportName ="";
        //ExportReport4.jasperExportReport4.jasper
        if(export.equalsIgnoreCase("1")){
  reportName = "src/reports/OriginalExport.jasper";
        }
        else if(export.equalsIgnoreCase("0")){
         reportName = "src/reports/ExportReport4.jasper";
 
        }
//  InputStream is = this.getClass().getClassLoader().getResourceAsStream(reportName);
  InputStream in=new FileInputStream(reportName);
  
  if(in==null|| connection==null) return ;
  JasperPrint jp = JasperFillManager.fillReport(in, null, connection);
  System.out.println("Object of Jasper Print created");
 
  
              JRViewer jv = new JRViewer(jp);
 
     //Insert viewer to a JFrame to make it showable
            JFrame jf = new JFrame();
            jf.getContentPane().add(jv);
            jf.validate();
            jf.setVisible(true);
            jf.setSize(new Dimension(800,600));
            jf.setLocation(300,100);
            jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                /*
   * 
   * 
  File f=new File(reportName);
  if(f.exists()) System.out.println("Yes Yes File is there");
  else 
  System.out.println("File is not there"+f.getAbsolutePath());
   */
  
   }catch(Exception e){
    e.printStackTrace();}
    
    }// showReports

}

請幫助我很擔心

編輯:我正在 JRViewer 中查看文件,然后簡單地打印它,當我從 ireport netbean 插件另存為 pdf 時,也只有標題出現我不知道是什么問題,

嘗試更改 Jframe 的大小。 還嘗試首先將您的報告導出為文件(使用任何 JRExporter 實現),以查看生成的報告是否正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM