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(); }