ireport、jasperreport studio 导出excel有白色背景

ireport导出excel有白色背景


现象




ireport导出excel去掉白色背景,解决办法

ireport开发工具,
工具----》选项---》iReport---》export options---》excel----》去掉white page background




jasperreport studio导出excel去掉白色背景,解决办法



显示正常





程序中,去掉白色背景,解决办法

在导出器中,设置配置。

				JRXlsxExporter exporter = new JRXlsxExporter();
				
				
				//设置导出时参数
				SimpleXlsxReportConfiguration conf = new SimpleXlsxReportConfiguration();
				conf.setWhitePageBackground(false);
				conf.setDetectCellType(true);
				exporter.setConfiguration(conf);

完整代码

	public void testExportExcel() throws JRException{
		System.out.println(System.getProperty("user.dir"));
		String sourceFileName = "D:/eclipse_workspace/test_Report.jrxml";
		long starttime = System.currentTimeMillis();
		
		//jasper文件
		JasperReport jasperReport = JasperCompileManager.compileReport(sourceFileName);
		long endtime1 = System.currentTimeMillis();
		System.out.println("第一次编译共用时:"+((endtime1-starttime)/1000));
		
		//填充报表的参数
		Map<String,Object> params  = new HashMap<String,Object>();
		
		List<ReportVO<MemberConsumeInfo>>  beanCollection = CustomerReportFactoryBean.getMemberConsumeList();
		JRDataSource dataSource = new JRBeanCollectionDataSource(beanCollection, true);
		//print文件
		JasperPrint print =  JasperFillManager.fillReport(jasperReport, params, dataSource);
		System.out.println("打印文件是:"+print);
		
		//如果只注明文件名字,默认会生成在user.dir
		String fileName = "asfdsf1.xlsx";
		
		//设置导出时参数
		SimpleXlsxReportConfiguration conf = new SimpleXlsxReportConfiguration();
		conf.setWhitePageBackground(false);
		conf.setDetectCellType(true);
		
		JRXlsxExporter exporter = new JRXlsxExporter();
		exporter.setConfiguration(conf);
		
		
		//设置输入项
		ExporterInput exporterInput = new SimpleExporterInput(print);
		exporter.setExporterInput(exporterInput);
		
		//设置输出项
		OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(fileName);
		exporter.setExporterOutput(exporterOutput);
		
		
		exporter.exportReport();
	}


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值