Olá, tenho uma lista com as informação da tabela do banco de dados.
Preciso criar um arquivo xlsx para cada linha dessa tabela.
No código que eu fiz, ele gera os arquivos, mas somente o último arquivo abre.
Poderiam me ajudar, por favor?
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File("C:/temp/comissaoXLSX.xlsx"));
ComissaoPagaDAOPorPlataforma dao = new ComissaoPagaDAOPorPlataforma();
List<ComissaoPaga> listaPlataforma = dao.obterComissoesPorPlataforma();
SXSSFRow cabecalho = firstSheet.createRow(0);
SXSSFCell Coluna3 = cabecalho.createCell(0);
Coluna3.setCellValue("ID_PLATAFORMA");
Coluna3.setCellStyle(estilo);
firstSheet.setColumnWidth((short) (0), (short) (4000));
//int i = 1;
for (ComissaoPaga comissaoPaga : listaPlataforma) {
int i = 1;
SXSSFRow row = firstSheet.createRow(i);
if(comissaoPaga.getIdPlataforma() == null) {
row.createCell(0).setCellValue("");
} else {
fos = new FileOutputStream(new File("C:/temp/"+comissaoPaga.getIdPlataforma()+".xlsx"));
SXSSFCell idPlataforma = row.createCell(0); // ou >> row.createCell(2).setCellValue(comissaoPaga.getIdPlataforma());
idPlataforma.setCellValue(comissaoPaga.getIdPlataforma());
idPlataforma.setCellStyle(estilolinhas);
}
System.out.println(comissaoPaga);
i++;
}