Last active
October 1, 2020 05:54
-
-
Save mistergamarra/1cc8f505b8ede46ebeb5d0dc2ecc4f16 to your computer and use it in GitHub Desktop.
This requieres FileCreator.java in order to do something
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
public class ArchivoApiController { | |
@Autowired | |
private FileCreator fileCreator; | |
@GetMapping("/report") | |
public ResponseEntity<byte[]> generateReport(String filename) { | |
HttpHeaders header = new HttpHeaders(); | |
header.setContentType("application/octet-stream"); | |
header.setContentLength(bytes.length); | |
header.set(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + (filename + ".xlsx") + "\""); | |
byte[] file = genericCall(); | |
return new ResponseEntity<byte[]>(file, headers, HttpStatus.OK); | |
} | |
private byte[] genericCall() { | |
XSSFSheet hoja = fileCreator.aperturarWorkbook("hoja1"); | |
// le agregas filas y columnas a la "hoja" | |
return fileCreator.crearExcel(hoja.getWorkbook()); // pasas el worbook de "la hoja" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment