Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java mailDb+“/”+cellulareDB+“/” +telefonoDB+“/”+indirizzoDB+“/”+capDB+“/”+cittaDB+“/”+provinciaDB +“/”+ATENODB+“/”+estrazioneDb); Row Row=sheet.createRow(rigaExcel); row.setRowStyle(空); 对于(int cella=0;cella_Java_Mysql_Apache Poi - Fatal编程技术网

Java mailDb+“/”+cellulareDB+“/” +telefonoDB+“/”+indirizzoDB+“/”+capDB+“/”+cittaDB+“/”+provinciaDB +“/”+ATENODB+“/”+estrazioneDb); Row Row=sheet.createRow(rigaExcel); row.setRowStyle(空); 对于(int cella=0;cella

Java mailDb+“/”+cellulareDB+“/” +telefonoDB+“/”+indirizzoDB+“/”+capDB+“/”+cittaDB+“/”+provinciaDB +“/”+ATENODB+“/”+estrazioneDb); Row Row=sheet.createRow(rigaExcel); row.setRowStyle(空); 对于(int cella=0;cella,java,mysql,apache-poi,Java,Mysql,Apache Poi,有什么不对劲吗? 你能帮我吗?candRecall=cellStylecandfisato=cellStylecandKo=cellStyle我已将边框添加到所有样式中,现在我已确定行的高度为“0” public static void scriviExcelDaDb(String nomeFile, int idLista) throws Exception { String query = ""; String foglio = "Candidati"; // ateneo

有什么不对劲吗?
你能帮我吗?

candRecall=cellStyle
candfisato=cellStyle
candKo=cellStyle我已将边框添加到所有样式中,现在我已确定行的高度为“0”
public static void scriviExcelDaDb(String nomeFile, int idLista) throws Exception {
    String query = "";
    String foglio = "Candidati"; // ateneo + "_" + corso + "_" +
                                    // idEstrazione;
    nomeFile = nomeFile + "(da DB).xlsx";
    System.out.println("Inizio a scivere l'Excel " + nomeFile);
    Workbook workbook = new XSSFWorkbook();
    Sheet sheet = workbook.createSheet(foglio);

    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(nomeFile);
        System.out.println("Preparo la riga di intestazione");
        sheet.setDefaultRowHeight((short) 15);
        CellStyle headerCellStyle = workbook.createCellStyle();
        //XSSFColor myColor = new XSSFColor(Color.decode("#00CCFF"));
        headerCellStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());
        headerCellStyle.setBorderBottom(BorderStyle.THICK);
        headerCellStyle.setBorderLeft(BorderStyle.THICK);
        headerCellStyle.setBorderRight(BorderStyle.THICK);
        headerCellStyle.setBorderTop(BorderStyle.THICK);
        headerCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        headerCellStyle.setWrapText(true);
        Row headerRow = sheet.createRow(0);

        for (int cella = 0; cella < 10; cella++) {
            headerRow.createCell(cella);
            headerRow.getCell(cella).setCellStyle(headerCellStyle);
        }

        headerRow.getCell(0).setCellValue("STATO");
        headerRow.getCell(1).setCellValue("COGNOME");
        headerRow.getCell(2).setCellValue("NOME");
        headerRow.getCell(3).setCellValue("E-MAIL");
        headerRow.getCell(4).setCellValue("CELLULARE");
        headerRow.getCell(5).setCellValue("TELEFONO");
        headerRow.getCell(6).setCellValue("INDIRIZZO");
        headerRow.getCell(7).setCellValue("CAP");
        headerRow.getCell(8).setCellValue("CITTA");
        headerRow.getCell(9).setCellValue("PROVINCIA");
        for (int cella = 0; cella < 10; cella++) {
            headerRow.getCell(cella).setCellStyle(headerCellStyle);

        }

        // workbook.write(fos);
        // fos.flush();
        System.out.println("Scrivo la riga di Intestazione");

        try {
            Class.forName(JDBC);
            // carica la classe del driver

            // stabilisce la connessione
            Connection connessione = DriverManager.getConnection(DB_URL, USER_DB, PWD);
            Statement stat = connessione.createStatement();

            query = "select s.id_stato ,s.descrizione, c.nome, c.cognome, c.email, c.cellulare,c.telefono,c.indirizzo, "
                    + "c.cap,c.citta,c.provincia,l.ateneo,l.estrazione "
                    + "from candidati as c,liste as l, stato_candidato s " + "where c.id_lista=l.id_lista "
                    + "and c.stato_call=s.id_stato " + "and c.id_lista = " + idLista + " " + "order by c.cognome; ";

            System.out.println("Recupero i dati dal DB");
            ResultSet candidati = stat.executeQuery(query);
            int numeroRighe = InviaMail.getRows(candidati);

            int rigaExcel = 0;
            sheet = workbook.getSheet(foglio);
            CellStyle cellStyle = workbook.createCellStyle();

            cellStyle.setBorderBottom(BorderStyle.THIN);
            cellStyle.setBorderLeft(BorderStyle.THIN);
            cellStyle.setBorderRight(BorderStyle.THIN);
            cellStyle.setBorderTop(BorderStyle.THIN);

            CellStyle candRecall = workbook.createCellStyle();
            candRecall = cellStyle;
            candRecall.setFillForegroundColor(IndexedColors.GOLD.getIndex());
            candRecall.setFillPattern(FillPatternType.SOLID_FOREGROUND);

            CellStyle candFissato = workbook.createCellStyle();
            candFissato = cellStyle;
            candFissato.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
            candFissato.setFillPattern(FillPatternType.SOLID_FOREGROUND);

            CellStyle candKo = workbook.createCellStyle();
            candKo = cellStyle;
            candKo.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
            candKo.setFillPattern(FillPatternType.SOLID_FOREGROUND);

            while (candidati.next() && !candidati.isClosed()) {
                rigaExcel++;
                System.out.println("Preparo la riga n°: " + rigaExcel + " di " + numeroRighe);
                int idStatoInvioDB = candidati.getInt("s.id_stato");
                String statoInvioDB = candidati.getString("s.descrizione");
                String nomeDb = candidati.getString("c.nome");
                String cognomeDb = candidati.getString("c.cognome");
                String emailDb = candidati.getString("c.email");
                String cellulareDB = candidati.getString("c.cellulare");
                String telefonoDB = candidati.getString("c.telefono");
                String indirizzoDB = candidati.getString("c.indirizzo");
                String capDB = candidati.getString("c.cap");
                String cittaDB = candidati.getString("c.citta");
                String provinciaDB = candidati.getString("c.provincia");
                String ateneoDb = candidati.getString("l.ateneo");
                String estrazioneDb = candidati.getString("l.estrazione");

                System.out.println("Riga n°:" + rigaExcel + " di " + numeroRighe + " scritta: " + statoInvioDB
                        + " / " + nomeDb + " / " + cognomeDb + " / " + emailDb + " / " + cellulareDB + " / "
                        + telefonoDB + " / " + indirizzoDB + " / " + capDB + " / " + cittaDB + " / " + provinciaDB
                        + " / " + ateneoDb + " / " + estrazioneDb);

                Row row = sheet.createRow(rigaExcel);
                row.setRowStyle(null);
                for (int cella = 0; cella < 10; cella++) {
                    boolean stylato = false;
                    //row.createCell(cella);

                    if (idStatoInvioDB == 3) {
                        Cell cell =  row.createCell((short) cella);
                        cell.setCellStyle(candRecall);
                        stylato = true;
                    }
                    if (idStatoInvioDB == 5) {
                        Cell cell =  row.createCell((short) cella);
                        cell.setCellStyle(candFissato);
                        stylato = true;
                    }
                    if (idStatoInvioDB == 6) {
                        Cell cell =  row.createCell((short) cella);
                        cell.setCellStyle(candKo);
                        stylato = true;
                    }
                    if (!stylato) {
                        Cell cell =  row.createCell((short) cella);
                        cell.setCellStyle(cellStyle);
                    }

                }

                row.getCell(0).setCellValue(statoInvioDB);
                row.getCell(1).setCellValue(nomeDb);
                row.getCell(2).setCellValue(cognomeDb);
                row.getCell(3).setCellValue(emailDb);
                row.getCell(4).setCellValue(cellulareDB);
                row.getCell(5).setCellValue(telefonoDB);
                row.getCell(6).setCellValue(indirizzoDB);
                row.getCell(7).setCellValue(capDB);
                row.getCell(8).setCellValue(cittaDB);
                row.getCell(9).setCellValue(provinciaDB);
                //row.getCell(10).setCellValue(idStatoInvioDB);
                // workbook.write(fos);
                // fos.flush();
            }

            for (int cella = 0; cella < 10; cella++) {
                sheet.autoSizeColumn(cella);
            }

            workbook.write(fos);
            fos.flush();
            fos.close();
            workbook.close();
            System.out.println("File Excel: " + nomeFile + " generato");
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            System.out.println(query);
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

}