public ExportZipArchive add(final String filename, final ExportWorkbook exportWorkbook) { zipFiles.add(new ExportZipFile(filename, exportWorkbook)); return this; }
public void write(final OutputStream out) { final ZipOutputStream zipOut = new ZipOutputStream(out); try { zipOut.putNextEntry(new ZipEntry(filename + "/")); for (final ExportZipFile file : zipFiles) { final ZipEntry zipEntry = new ZipEntry(filename + "/" + file.getFilename()); zipOut.putNextEntry(zipEntry); if (file.getExportObject() instanceof ExportWorkbook) { final ExportWorkbook workbook = (ExportWorkbook) file.getExportObject(); final byte[] xls = workbook.getAsByteArray(); if (xls == null || xls.length == 0) { log.error("Oups, xls has zero size. Filename: " + filename); continue; } zipOut.write(xls); } else if (file.getExportObject() instanceof ExportJFreeChart) { final ExportJFreeChart exportJFreeChart = (ExportJFreeChart) file.getExportObject(); exportJFreeChart.write(zipOut); } zipOut.closeEntry(); } } catch (final IOException ex) { log.error(ex.getMessage(), ex); throw new RuntimeException(ex); } finally { IOUtils.closeQuietly(zipOut); } }
public ExportZipArchive add(final String filename, final ExportJFreeChart exportJFreeChart) { zipFiles.add(new ExportZipFile(filename, exportJFreeChart)); return this; }
public ExportZipArchive add(final ExportWorkbook exportWorkbook) { zipFiles.add(new ExportZipFile(exportWorkbook.getFilename(), exportWorkbook)); return this; }