Change XSSFWorkbook to HSSFWorkbook when serializing data to excel, and flushing OutputStream immediately once writing succeed.