Erro ao gerar documento Word Java

0 respostas
java-seprogramaçãojava
F

Estou desenvolvendo uma aplicação java para desktop em que pego os dados do meu banco de dados e coloco em uma table, mas ao clicar no botão de imprimir e gerar o documento Word ele aparece o seguinte erro.

Erroorg.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /docProps/app.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@1ee86a77

EstoqueDAO

public void gerarIventario() {

    FileOutputStream out = null;
    XWPFDocument document = new XWPFDocument();

    try {
        out = new FileOutputStream(new File("Iventario.docx"));

        XWPFParagraph paragrafo1 = document.createParagraph();
        XWPFRun runPagina1 = paragrafo1.createRun();
        runPagina1.setText("Iventario dos Produtos do Estoque");

        runPagina1.setBold(true);
        runPagina1.addBreak();
        runPagina1.addBreak();

        XWPFParagraph paragrafo2 = document.createParagraph();
        XWPFRun runPagina2 = paragrafo2.createRun();
        runPagina2.setText("eefefefef");

        XWPFParagraph paragrafo3 = document.createParagraph();
        XWPFRun runPagina3 = paragrafo3.createRun();
        runPagina3.setText("Telfone:(11)4444444");

        XWPFParagraph paragrafo4 = document.createParagraph();
        XWPFRun runPagina4 = paragrafo4.createRun();
        runPagina3.setText("CNPJ:1221333.33");

        XWPFParagraph paragrafo5 = document.createParagraph();
        XWPFRun runPagina5 = paragrafo5.createRun();
        runPagina3.setText("Email:Feleeffefefefe");
        runPagina3.addBreak();
        runPagina3.addBreak();

        XWPFParagraph paragrafo6 = document.createParagraph();
        XWPFRun runPagina6 = paragrafo6.createRun();
        runPagina6.setText("Lista de Produtos ");

        runPagina6.setBold(true);
        runPagina6.addBreak();

        XWPFParagraph paragrafo7 = document.createParagraph();
        XWPFRun runPagina7 = paragrafo6.createRun();
        runPagina7.setText("Iventario do dia:" + data + "Realizado as:" + horaAtual);

        runPagina7.setBold(true);
        runPagina7.addBreak();
        
        

        try {
            
             try {
        con = Conecta.conexao();
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(EntradaMaquinaDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
            statement = con.createStatement();

            String sql = "Select esto_cod, esto_descricao, esto_categoria,esto_sub_categoria, esto_hora, esto_data, esto_qtde, esto_qtde_min,esto_tipo,esto_preco_medio,esto_preco from tb_estoque";
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next()) {

                //create table
                XWPFTable table = document.createTable();

                //create first row
                XWPFTableRow tableRowOne = table.getRow(0);

                tableRowOne.getCell(0).setText("Codigo");
                tableRowOne.addNewTableCell().setText("Descricao");
                tableRowOne.addNewTableCell().setText("Categoria");

                 tableRowOne.addNewTableCell().setText("Codigo");
                tableRowOne.addNewTableCell().setText("Descricao");
                tableRowOne.addNewTableCell().setText("Categoria");
                tableRowOne.addNewTableCell().setText("Sub-Categoria");
                tableRowOne.addNewTableCell().setText("Hora ultima Compra");
                tableRowOne.addNewTableCell().setText("Data ultima compra");
                tableRowOne.addNewTableCell().setText("Quantidade");
                tableRowOne.addNewTableCell().setText("Quantidade Minima");
                tableRowOne.addNewTableCell().setText("tipo");
                tableRowOne.addNewTableCell().setText("Preço Médio");
                tableRowOne.addNewTableCell().setText("Preço Total");

                XWPFTableRow tableRowTwo = table.createRow();
                
               tableRowTwo.getCell(0).setText(rs.getString("esto_cod"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_descricao"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_categoria"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_sub_categoria"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_hora"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_data"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_qtde"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_qtde_min"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_tipo"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_preco_medio"));
                tableRowTwo.addNewTableCell().setText(rs.getString("esto_preco"));

                
         document.write(out);
  out.close();
            }

        } catch (SQLException ex) {
            System.out.println("Erro banco" + ex);
        }
               

    } catch (Exception e) {
         System.out.println("Erro" + e);
    }

}
Criado 21 de dezembro de 2017
Respostas 0
Participantes 1