Skip to content

Commit 41a027c

Browse files
authored
Update ExcelController.java
1 parent afffcdc commit 41a027c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

apache-poi-3/src/main/java/com/baeldung/hssfworkbook/ExcelController.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public ResponseEntity<byte[]> downloadExcel() {
2727
byte[] bytes = baos.toByteArray();
2828

2929
return ResponseEntity.ok()
30-
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=employee_data.xls")
31-
.contentType(MediaType.parseMediaType("application/vnd.ms-excel")) // More specific MIME type
32-
.body(bytes);
30+
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=employee_data.xls")
31+
.contentType(MediaType.parseMediaType("application/vnd.ms-excel")) // More specific MIME type
32+
.body(bytes);
3333
}
3434
} catch (IOException e) {
3535
System.err.println("Error generating or writing Excel workbook: " + e.getMessage());
3636
return ResponseEntity.internalServerError()
37-
.build();
37+
.build();
3838
}
3939
}
4040

@@ -54,11 +54,12 @@ public ResponseEntity<String> uploadExcel(@RequestParam("file") MultipartFile fi
5454
} catch (IOException e) {
5555
System.err.println("Error processing uploaded Excel file: " + e.getMessage());
5656
return ResponseEntity.internalServerError()
57-
.body("Failed to process the Excel file.");
57+
.body("Failed to process the Excel file.");
5858
} catch (Exception e) {
5959
System.err.println("An unexpected error occurred during file upload: " + e.getMessage());
6060
return ResponseEntity.internalServerError()
61-
.body("An unexpected error occurred.");
61+
.body("An unexpected error occurred.");
6262
}
6363
}
64-
}
64+
65+
}

0 commit comments

Comments
 (0)