iReport笔记之打印图形

2008-07-18 20:07:42.0     浏览:578     来源:巧巧读书
关键词:  iReport     打印  

打印如下样式的报表

iReport 笔记之打印图形(图一)

有了前面的例子,这个倒没什么特别的,使用图形控件,将其“Image Express”设为图形路径即可,如下图所示:

iReport 笔记之打印图形(图二)

使用的数据源Bean类如下:

package lld.test.ireport;

public class AnimalBean
{
private String animalName;

private String imagePath;
public String getAnimalName()
{
return animalName;
}
public void setAnimalName(String animalName)
{
this.animalName = animalName;
}
public String getImagePath()
{
return imagePath;
}
public void setImagePath(String imagePath)
{
this.imagePath = imagePath;
}
}生成数据源的函数如下所示:

private JRDataSource createDataSource()
{
//生成测试数据
ArrayList<AnimalBean> beans = new ArrayList<AnimalBean>();

String root_path = this.getServletContext().getRealPath("/");
root_path = root_path.replace(''\\'', ''/'');
root_path = root_path + "image/";

AnimalBean dog_bean = new AnimalBean();
dog_bean.setAnimalName("doggy");
dog_bean.setImagePath(root_path + "doggy.jpg");
beans.add(dog_bean);

AnimalBean mouse_bean = new AnimalBean();
mouse_bean.setAnimalName("mouse");
mouse_bean.setImagePath(root_path + "mouse.jpg");
beans.add(mouse_bean);

return new JRBeanCollectionDataSource(beans);
}注: 如需本例代码, 请留言或发邮件至lldwolf@163.com索取