如何在java中附加excel文件并使用JRXlsExporter编写该文件
我有一个excel文件,我想在该文件末尾添加新数据。如何在java中附加excel文件并使用JRXlsExporter编写该文件,java,excel,jasper-reports,Java,Excel,Jasper Reports,我有一个excel文件,我想在该文件末尾添加新数据。 为此,我使用这种方法 public static void exportXLS(JasperPrint jasperPrint, String fileName) throws IOException, JRException{ SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); configurati
为此,我使用这种方法
public static void exportXLS(JasperPrint jasperPrint, String fileName) throws IOException, JRException{
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
configuration.setOnePagePerSheet(true);
configuration.setDetectCellType(true);
configuration.setCollapseRowSpan(false);
configuration.setWhitePageBackground(false);
File file = new File(fileName+".xls");
FileOutputStream fos = new FileOutputStream(file,true);
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setExporterInput(new SimpleExporterInput(jasperPrint));
exporterXLS.setExporterOutput(new SimpleOutputStreamExporterOutput(fos));
exporterXLS.setConfiguration(configuration);
exporterXLS.exportReport();
}
我已将FileOutputStream构造函数的append参数设置为true,但仍然不起作用。当我打开文件时,我只找到新数据,而不是旧数据