我正在使用 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 时,也只有标题出现,我不知道是什么问题,