Package fr.becpg.repo.helper
Class ExcelStreamHelper
java.lang.Object
fr.becpg.repo.helper.ExcelStreamHelper
Writes a streamed workbook to a file every spreadsheet application can open.
A streamed workbook is written to a plain output stream, so its writer does not know the size of an entry before writing it and leaves that size out of the local header of the zip entry, to publish it in a trailing data descriptor. Spreadsheet applications reading the local headers - LibreOffice among them - then declare the file corrupted and offer to repair it, although its content is complete. The entries are therefore copied, still compressed, into a file the zip writer can seek back into to complete each header.- Version:
- $Id: $Id
- Author:
- matthieu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voiddeleteQuietly(File file) private static voidCopy every entry of a zip file, as compressed as it already is, into a seekable one.static voidwriteWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook workbook, File target) Write the given streamed workbook to the target file.
-
Field Details
-
logger
private static final org.apache.commons.logging.Log logger -
TEMP_FILE_PREFIX
- See Also:
-
XLSX_EXTENSION
- See Also:
-
-
Constructor Details
-
ExcelStreamHelper
private ExcelStreamHelper()
-
-
Method Details
-
writeWorkbook
public static void writeWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook workbook, File target) throws IOException Write the given streamed workbook to the target file.
- Parameters:
workbook- aSXSSFWorkbookobjecttarget- aFileobject- Throws:
IOException- if the workbook cannot be written
-
repack
Copy every entry of a zip file, as compressed as it already is, into a seekable one.- Parameters:
source- aFileobjecttarget- aFileobject- Throws:
IOException- if an entry cannot be copied
-
deleteQuietly
-