[poi] Se informa un error al usar poi: java.io.EOFException: final inesperado del flujo de entrada ZLIB

error de tipografía

Workbook workbook = null;
try {
    // 会报错
    File file = new File("D:\\1.xlsx");
    workbook = new XSSFWorkbook(file);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
	workbook.write(baos);
	workbook.close();
	bytes = baos.toByteArray();
} catch (Exception e) {
    e.printStackTrace();
}

ortografía correcta

Workbook workbook = null;
try {
	File file = new File("D:\\1.xlsx");
    workbook = new XSSFWorkbook(new FileInputStream(file));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
	workbook.write(baos);
	workbook.close();
	bytes = baos.toByteArray();
} catch (Exception e) {
    e.printStackTrace();
}

Supongo que te gusta

Origin blog.csdn.net/qq_32088869/article/details/131954562
Recomendado
Clasificación