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