Example usage for org.apache.poi.hssf.usermodel HSSFWorkbook createSheet

List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook createSheet

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFWorkbook createSheet.

Prototype

@Override
public HSSFSheet createSheet(String sheetname) 

Source Link

Document

Create a new sheet for this Workbook and return the high level representation.

Usage

From source file:erp_frame.java

 private void btnExportMouseClicked(java.awt.event.MouseEvent evt) {
   String outputFile = "D:/ERPOutputFile/" + path + ".xls";
   switch (path) {
   case "":
      fields = employeeFields;/*from  www. j a v  a  2 s.  c o m*/
      break;
   case "":
      fields = attendanceFields;
      break;
   case "":
      fields = achivevmentFields;
      break;
   case "":
      fields = payRollFields;
      break;
   case "":
      fields = materialFields;
      break;
   case "?":
      fields = productFields;
      break;
   case "":
      fields = memberFields;
      break;
   case "":
      fields = orderListFields;
      break;
   case "":
      fields = orderItemFields;
      break;
   case "":
      fields = issueFields;
      break;
   case "":
      fields = vendorFields;
      break;
   case "?":
      fields = adminFields;
      break;
   case "":
      fields = purchaseFields;
      break;
   case "?":
      fields = payableFields;
      break;
   case "?":
      fields = assetFields;
      break;
   case "?":
      fields = billboardFields;
      break;
   case "?":
      fields = departFields;
      break;

   default:
      JOptionPane.showMessageDialog(JToolBar, "?");
      break;
   }
   try {
      // Create a excel file
      HSSFWorkbook workbook = new HSSFWorkbook();
      // Create a sheet with name
      HSSFSheet sheet = workbook.createSheet(path);
      HSSFRow row = null;
      HSSFCell cell = null;
      // set the sheet row count and set the first row data with title
      for (int i = 0; i < table_firmData.getRowCount() + 1; i++) {
         if (i == 0) {
            row = sheet.createRow((short) i);
            for (int k = 0; k < fields.length; k++) {
               cell = row.createCell((short) k);
               cell.setCellType(HSSFCell.CELL_TYPE_STRING);
               cell.setCellValue(fields[k]);
            }
         } else {
            // Insert table data in next row
            row = sheet.createRow((short) i);
            for (int k = 0; k < fields.length; k++) {
               cell = row.createCell((short) k);
               cell.setCellType(HSSFCell.CELL_TYPE_STRING);
               cell.setCellValue((String) table_firmData.getValueAt(i - 1, k));
            }

         }
      }
      FileOutputStream fOut = new FileOutputStream(outputFile);
      workbook.write(fOut);
      fOut.flush();
      fOut.close();
      JOptionPane.showMessageDialog(JToolBar, "?!\n ? :" + outputFile);
   } catch (Exception ee) {
      JOptionPane.showMessageDialog(JToolBar, " : " + ee.getMessage());
      System.out.println(ee.toString());
   }
}

From source file:Console.java

static public void exportToExcel(String sheetName, ArrayList headers, ArrayList data, File outputFile)
        throws HPSFException {

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet(sheetName);

    int rowIdx = 0;
    short cellIdx = 0;

    // Header//w w  w .j  av  a2 s . co  m
    HSSFRow hssfHeader = sheet.createRow(rowIdx);
    HSSFCellStyle cellStyle = wb.createCellStyle();
    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    for (Iterator cells = headers.iterator(); cells.hasNext();) {
        HSSFCell hssfCell = hssfHeader.createCell(cellIdx++);
        hssfCell.setCellStyle(cellStyle);
        hssfCell.setCellValue((String) cells.next());
    }
    // Data
    rowIdx = 1;
    for (Iterator rows = data.iterator(); rows.hasNext();) {
        ArrayList row = (ArrayList) rows.next();
        HSSFRow hssfRow = sheet.createRow(rowIdx++);
        cellIdx = 0;
        for (Iterator cells = row.iterator(); cells.hasNext();) {
            HSSFCell hssfCell = hssfRow.createCell(cellIdx++);
            Object o = cells.next();
            if ("class java.lang.Double".equals(o.getClass().toString())) {
                hssfCell.setCellValue((Double) o);
            } else {
                hssfCell.setCellValue((String) o);
            }

        }
    }

    wb.setSheetName(0, sheetName);
    try {
        FileOutputStream outs = new FileOutputStream(outputFile);
        wb.write(outs);
        outs.close();
        //            System.out.println("Archivo creado correctamente en " + outputFile.getAbsolutePath());
    } catch (IOException e) {
        e.printStackTrace();
        throw new HPSFException(e.getMessage());
    }
}

From source file:Adicionales.Abrir_xml.java

private void ExportarEtiquetasXml(HSSFWorkbook workbook, Document document, String nombre) {
    System.out.println("Exportando : " + nombre);
    try {/*from w w  w  .j  a va  2 s.  c om*/
        HSSFSheet sheet = workbook.createSheet(tipo_comprobante + " " + (nombres.indexOf(nombre) + 1));
        System.out.println("Primera vez creada");
        HSSFCellStyle cellStyle = workbook.createCellStyle();
        HSSFRow rowTag = sheet.createRow(0);
        HSSFRow RowData = sheet.createRow(1);
        NodeList nodeList = document.getElementsByTagName("*");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Element element = (Element) nodeList.item(i);
            if (element.getChildNodes().getLength() == 1 && !element.getNodeName().contains(":")) {
                if (element.getFirstChild().getNodeType() == Node.TEXT_NODE
                        && !element.getNodeName().equals("comprobante")) {
                    HSSFCell cellTag = rowTag.createCell(i);
                    cellTag.setCellValue(element.getNodeName());
                    HSSFCell cellData = RowData.createCell(i);
                    cellData.setCellValue(element.getFirstChild().getNodeValue());
                    sheet.autoSizeColumn((short) i);
                    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cellTag.setCellStyle(cellStyle);
                } else {
                    DocumentBuilderFactory sub_factory = DocumentBuilderFactory.newInstance();
                    DocumentBuilder sub_builder = sub_factory.newDocumentBuilder();
                    Document sub_document = sub_builder
                            .parse(new InputSource(new StringReader(element.getFirstChild().getNodeValue())));
                    NodeList sub_nodeList = sub_document.getElementsByTagName("*");
                    for (int j = 0; j < sub_nodeList.getLength(); j++) {
                        Element sub_element = (Element) sub_nodeList.item(j);
                        if (sub_element.getNodeName().equals("Signature"))
                            break;
                        if (sub_element.getChildNodes().getLength() == 1
                                && !sub_element.getNodeName().contains(":")) {
                            if (sub_element.getFirstChild().getNodeType() == Node.TEXT_NODE) {
                                HSSFCell cellTag = rowTag.createCell(j);
                                cellTag.setCellValue(sub_element.getNodeName());
                                HSSFCell cellData = RowData.createCell(j);
                                cellData.setCellValue(sub_element.getFirstChild().getNodeValue());
                                sheet.autoSizeColumn((short) j);
                                cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
                                cellTag.setCellStyle(cellStyle);
                            }
                        }
                    }
                }
            }
        }
    } catch (IOException e) {
        System.out.println(e.getMessage());
    } catch (IllegalArgumentException e) {
        JOptionPane.showMessageDialog(null, "<html>Error al exportar archivo " + nombre
                + "<br>Verificar maximo de etiquetas soportadas [255]</html>");
    } catch (ParserConfigurationException e) {
        System.out.println("ParserConfigurationException " + e.getMessage());
    } catch (SAXException e) {
        System.out.println("SAXException " + e.getMessage());
    }
}

From source file:android_connector.ConfigWindowController.java

/**
 * Speichert die Ergebnisse der Lufe als Excel-Tabelle.
 *
 * @author Quelle://w w w  . j  a v a 2  s.c  om
 * http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/
 * @param programmende True, wenn das Programm beendet werden soll, sonst
 * false.
 *
 */
public void printResults(boolean programmende) {
    /**
     * Zahl der Messtore.
     */
    int tore = Integer.parseInt(messtore.getText());
    /**
     * Gibt die gespeicherten Werte der DB an. Jedes Unterarray
     * reprsentiert einen Datensatz. Der zweite Index ist bei 0 die
     * Startnummer, 1 der Name, 2 die Kategorie, 3 Lauf 1, 4 Lauf 2.
     */
    String[][] werte = (new MySQLConnection(host.getText(), port.getText(), db.getText(), user.getText(),
            pw.getText(), null)).getAuswertung(starter, tore);
    //FileChooser einsetzen, um Speicherort zu ermitteln
    FileChooser fc = new FileChooser();
    //Titel anzeigen
    fc.setTitle("Speicherort fr die Auswertung:");
    //standardmig im Home-Verzeichnis starten
    fc.setInitialDirectory(new File(System.getProperty("user.home")));
    //Alle-Dateien-Filter entfernen
    fc.setSelectedExtensionFilter(null);
    //FileFilter fr Exceldateien hinzufgen
    //nur "alte" Excel-Dateien knnen geschrieben werden!
    fc.getExtensionFilters()
            .addAll(new FileChooser.ExtensionFilter("Microsoft Excel 1997-2003 Dokument (.xls)", "*.xls"));
    //Dateien einlesen
    File returnVal = fc.showSaveDialog(primaryStage);
    //prfen, ob Datei zurckgegeben --> eine gewhlt; muss aber nicht existieren
    if (returnVal != null) {
        /**
         * Reprsentation der Excel-Datei.
         */
        HSSFWorkbook workbook = new HSSFWorkbook();
        /**
         * Alle Kategorien, die angegeben sind.
         */
        List<String> kategorien = getKategorien();
        //alle Kategorien durchgehen, fr alle eine Mappe der DB fllen.
        for (String kategorie : kategorien) {
            /**
             * Reprsentiert die Mappe, in der die Daten landen.
             */
            HSSFSheet sheet;
            //Prfen, ob die Lnge des Kategorienamens zwischen 1 und 31 liegt --> sonst ungltig
            if (!kategorie.isEmpty() && kategorie.length() < 31) {
                //wenn ja: Kategoriename ist Mappenname
                sheet = workbook.createSheet(kategorie);
                //sonst: Standardname
            } else {
                sheet = workbook.createSheet("namenlose Kategorie");
            }

            Map<String, List<String>> data = new HashMap<String, List<String>>();
            List<String> label = new ArrayList<>();
            label.add("Startnummer");
            label.add("Name");
            label.add("Kategorie");
            label.add("reine Laufzeit- Lauf 1");
            label.add("Gesamtstrafen- Lauf 1");
            label.add("Laufzeit insgesamt- Lauf 1");
            for (int i = 0; i < tore; i++) {
                label.add("Strafe Tor " + (i + 1));
            }
            label.add("reine Laufzeit- Lauf 2");
            label.add("Gesamtstrafen- Lauf 2");
            label.add("Laufzeit insgesamt- Lauf 2");
            for (int i = 0; i < tore; i++) {
                label.add("Strafe Tor " + (i + 1));
            }
            data.put("0", label);

            for (int i = 0; i < werte.length; i++) {
                //data.put(""+(i+2), werte[i]);
                if (werte[i][2] != null) {
                    if (werte[i][2].equals(kategorie)) {
                        List<String> angaben = new ArrayList<>();
                        angaben.add(werte[i][0]);
                        angaben.add(werte[i][1]);
                        angaben.add(werte[i][2]);
                        String lauf1 = werte[i][3];
                        if (werte[i][3] != null && !werte[i][3].isEmpty()) {
                            angaben.addAll(extractList(lauf1));
                        }
                        if (werte[i][4] != null && !werte[i][4].isEmpty()) {
                            angaben.addAll(extractList(werte[i][4]));
                        }
                        data.put("" + (i + 1), angaben);
                    }
                }
            }
            Set<String> keyset = data.keySet();
            int rownum = 0;
            for (String key : keyset) {
                Row row = sheet.createRow(rownum++);
                List<String> objArr = data.get(key);
                int cellnum = 0;
                for (Object obj : objArr) {
                    Cell cell = row.createCell(cellnum++);
                    if (obj instanceof Date) {
                        cell.setCellValue((Date) obj);
                    } else if (obj instanceof Boolean) {
                        cell.setCellValue((Boolean) obj);
                    } else if (obj instanceof String) {
                        cell.setCellValue((String) obj);
                    } else if (obj instanceof Double) {
                        cell.setCellValue((Double) obj);
                    }
                }
            }
            for (int i = 0; i < 9 + 2 * tore; i++) {
                sheet.autoSizeColumn(i);
            }
        }
        try {
            FileOutputStream out = new FileOutputStream(returnVal);
            workbook.write(out);
            out.close();
            System.out.println("Excel written successfully..");
            out = new FileOutputStream(System.getProperty("user.home") + "/Kanu-s.a.M.-Notfall.xls");
            workbook.write(out);
            out.close();

        } catch (FileNotFoundException e) {
            MySQLConnection.staticExceptionDialog(e, "Schreibfehler",
                    "Auswertung konnte nicht geschrieben werden",
                    "Die Excel-Datei mit der Auswertung konnte nicht geschrieben werden. Bitte versuchen Sie es erneut!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (programmende) {
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setTitle("Programmende");
        alert.setHeaderText("Der Programmablauf ist beendet.");
        alert.setContentText(
                "Das Programm hat seine Aufgabe erfllt und wird nun beendet. Vielen Dank fr die Benutzung des Softwaresystems!");
        alert.showAndWait();
        Platform.exit();
    }
}

From source file:attandance.standalone.manager.AttandanceManager.java

private void outputAttandance(List<LateRecord> lates, List<AbsenceRecord> absences) {
    // webbookExcel  
    HSSFWorkbook wb = new HSSFWorkbook();
    // webbooksheet,Excelsheet  
    HSSFSheet sheet = wb.createSheet("");
    int width = ((int) (20 * 1.14388)) * 256;
    sheet.setColumnWidth(0, width);/*from  w  w  w.j ava2 s .c o m*/
    sheet.setColumnWidth(1, width);
    sheet.setColumnWidth(2, width);
    sheet.setColumnWidth(3, width);
    // sheet0,??poiExcel?short  
    HSSFRow row = sheet.createRow((int) 0);
    // ?   
    HSSFCellStyle style = wb.createCellStyle();
    style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ?  

    HSSFCell cell = row.createCell((short) 0);
    cell.setCellValue("??");
    cell.setCellStyle(style);
    cell = row.createCell((short) 1);
    cell.setCellValue("");
    cell.setCellStyle(style);
    cell = row.createCell((short) 2);
    cell.setCellValue("?");
    cell.setCellStyle(style);
    cell = row.createCell((short) 3);
    cell.setCellValue("?");
    cell.setCellStyle(style);

    // ? ??   
    int i = 0;
    for (; i < lates.size(); i++) {
        row = sheet.createRow((int) i + 1);
        LateRecord lateStaff = lates.get(i);
        // ?  
        row.createCell((short) 0).setCellValue(lateStaff.getStaffName());
        row.createCell((short) 1).setCellValue(lateStaff.getCaculateDateString());
        cell = row.createCell((short) 2);
        cell.setCellValue(new SimpleDateFormat(DateHelper.DATE_FORMAT).format(lateStaff.getLateDate()));
        row.createCell((short) 3).setCellValue(lateStaff.getLateTimeDesc());
    }
    for (int j = 0; j < absences.size(); j++) {
        row = sheet.createRow((int) i + j + 1);
        AbsenceRecord absenceStaff = absences.get(j);
        // ?  
        row.createCell((short) 0).setCellValue(absenceStaff.getStaffName());
        row.createCell((short) 1).setCellValue(absenceStaff.getCaculateDateString());
        cell = row.createCell((short) 2);
        cell.setCellValue(
                new SimpleDateFormat(DateHelper.ONLY_DATE_FORMAT).format(absenceStaff.getAbsenceDate()));
        row.createCell((short) 3).setCellValue("?");
    }
    // ?  
    try {
        String fileName = "C:/xhuxing-private/" + new Date(System.currentTimeMillis()).getMonth()
                + ".xls";
        FileOutputStream fout = new FileOutputStream(fileName);
        wb.write(fout);
        fout.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:attheraces.ExportarParaExcel.java

private void criarUnicoArquivo() {
    FileOutputStream fos = null;/*from   w ww.  j a  v  a  2s  .  com*/
    try {
        HSSFWorkbook workbook = new HSSFWorkbook();
        File f = new File(caminho);

        fos = new FileOutputStream(f);

        int i = 1;
        HSSFSheet sheet = workbook.createSheet("Attherace");
        criarCabecalho(sheet);
        for (Informacoes inf : listagem) {
            addLinha(sheet, inf, i);
            i++;
        }

        workbook.write(fos);
    } catch (Exception e) {
        TrataException.fatal(e);
    } finally {
        try {
            fos.flush();
            fos.close();
        } catch (Exception e) {
            TrataException.fatal(e);
        }
    }
}

From source file:attheraces.ExportarParaExcel.java

private void criarUmArquivoPorMes() {
    try {//  ww w  .  jav a 2s  .  c  o  m
        String mesAnoAnterior = "";
        int i = 1;
        HSSFSheet sheet = null;
        HSSFWorkbook workbook = null;
        File f = null;
        FileOutputStream fos = null;
        for (Informacoes inf : listagem) {

            String mesAno = DataUtils.getDataFormatada(inf.getData(), "MM-yy");

            if (!mesAno.equals(mesAnoAnterior)) {

                if (workbook != null) {
                    workbook.write(fos);
                    fos.flush();
                    fos.close();
                }

                workbook = new HSSFWorkbook();
                f = new File(caminho + mesAno + ".xls");
                fos = new FileOutputStream(f);
                sheet = workbook.createSheet("Attheraces");
                i = 1;

                criarCabecalho(sheet);
            }

            addLinha(sheet, inf, i);

            mesAnoAnterior = mesAno;
            i++;
        }

        workbook.write(fos);
        fos.flush();
        fos.close();

    } catch (Exception e) {
        TrataException.fatal(e);
    }
}

From source file:attheraces.ExportarParaExcel.java

private void criarUmArquivoPorMesSeparadoEmAbas() {
    try {/*from   w w w  .j  a va  2 s.c o m*/
        String diaAnterior = "";
        String mesAnoAnterior = "";
        int i = 0;
        HSSFSheet sheet = null;
        HSSFWorkbook workbook = null;
        File f = null;
        FileOutputStream fos = null;
        for (Informacoes inf : listagem) {

            String dia = DataUtils.getDataFormatada(inf.getData(), "dd");
            String mesAno = DataUtils.getDataFormatada(inf.getData(), "MM-yy");

            if (!mesAno.equals(mesAnoAnterior)) {

                if (workbook != null) {
                    workbook.write(fos);
                    fos.flush();
                    fos.close();
                }

                workbook = new HSSFWorkbook();
                f = new File(caminho + mesAno + ".xls");
                fos = new FileOutputStream(f);
            }

            if (!dia.equals(diaAnterior)) {
                i = 0;
                sheet = workbook.createSheet(dia.split("/")[0]);
                criarCabecalho(sheet);
                i++;
            }

            addLinha(sheet, inf, i);

            diaAnterior = dia;
            mesAnoAnterior = mesAno;
            i++;
        }

        workbook.write(fos);
        fos.flush();
        fos.close();

    } catch (Exception e) {
        TrataException.fatal(e);
    }
}

From source file:BaseDatos.ExportarDatos.java

public void CrearExel() throws IOException {

    FileOutputStream archivoSalida = null;

    try {//w  ww.jav a  2s  . c  o  m
        Statement conexion = ConectarMysql.obtenerConexion().createStatement(ResultSet.CONCUR_READ_ONLY,
                ResultSet.TYPE_FORWARD_ONLY);
        HSSFWorkbook libro = new HSSFWorkbook();
        HSSFSheet hoja = libro.createSheet("reporte");
        String SqlVentas = "select * from ventas_realizadas";
        ResultSet resultado = conexion.executeQuery(SqlVentas);

        HSSFRow fila = hoja.createRow((short) 0);
        HSSFCell celda = fila.createCell(0);
        celda.setCellValue("nombre del producto");
        celda = fila.createCell(1);
        celda.setCellValue("fabricante");
        celda = fila.createCell(2);
        celda.setCellValue("contenedor");
        celda = fila.createCell(3);
        celda.setCellValue("cantidad");
        celda = fila.createCell(4);
        celda.setCellValue("precio Compra");
        celda = fila.createCell(5);
        celda.setCellValue("precio Venta");
        celda = fila.createCell(6);
        celda.setCellValue("fecha");
        if (resultado.first()) {
            int contador = 1;

            do {
                filaExel.clear();
                fila = hoja.createRow((short) contador);

                obtenerDatos(resultado.getInt(2));
                cantidad = resultado.getString(3);
                precioCompra = resultado.getString(4);
                precioVenta = resultado.getString(5);
                fecha = resultado.getString(6);
                filaExel.add(nombreProducto);
                filaExel.add(fabricante);
                filaExel.add(contenedor);
                filaExel.add(cantidad);
                filaExel.add(precioCompra);
                filaExel.add(precioVenta);
                filaExel.add(fecha);
                for (int a = 0; a < filaExel.size(); a++) {
                    celda = fila.createCell(a);
                    if (a == 3) {
                        celda.setCellValue(Integer.parseInt(filaExel.get(a)));
                    } else if (a == 4 || a == 5) {
                        celda.setCellValue(Double.parseDouble(filaExel.get(a)));
                    } else {
                        celda.setCellValue(filaExel.get(a));
                    }
                }
                this.operacion.setText("operando : " + contador);
                contador++;
            } while (resultado.next());

        }
        String direccionCompleta = "C:\\Users\\zombozo\\Documents\\ventas.xls";
        File archivo = new File(direccionCompleta);
        archivoSalida = new FileOutputStream(archivo);
        libro.write(archivoSalida);
        archivoSalida.close();
        conexion.close();
        JOptionPane.showMessageDialog(rootPane,
                "Creado Correctamente, busque el archivo en la carpeta documentos");
    } catch (Exception e) {
        JOptionPane.showMessageDialog(rootPane, "Ocurrio un error 1: " + e);
    }
}

From source file:BaseDatos.ExportarDatos.java

private void CrearExelCompras() {
    FileOutputStream archivoSalida = null;

    try {//from   w w w.  j  a  v  a 2 s  .com
        Statement conexion = ConectarMysql.obtenerConexion().createStatement(ResultSet.CONCUR_READ_ONLY,
                ResultSet.TYPE_FORWARD_ONLY);
        HSSFWorkbook libro = new HSSFWorkbook();
        HSSFSheet hoja = libro.createSheet("reporte");
        String SqlVentas = "select * from logCompras";
        ResultSet resultado = conexion.executeQuery(SqlVentas);

        HSSFRow fila = hoja.createRow((short) 0);
        HSSFCell celda = fila.createCell(0);
        celda.setCellValue("nombre del producto");
        celda = fila.createCell(1);
        celda.setCellValue("fabricante");
        celda = fila.createCell(2);
        celda.setCellValue("contenedor");
        celda = fila.createCell(3);
        celda.setCellValue("cantidad");
        celda = fila.createCell(4);
        celda.setCellValue("precio Compra");
        celda = fila.createCell(5);
        celda.setCellValue("precio Venta");
        celda = fila.createCell(6);
        celda.setCellValue("fecha");
        if (resultado.first()) {
            int contador = 1;

            do {
                filaExel.clear();
                fila = hoja.createRow((short) contador);

                obtenerDatos(resultado.getInt(2));
                cantidad = resultado.getString(3);
                precioCompra = resultado.getString(4);
                precioVenta = resultado.getString(5);
                fecha = resultado.getString(6);
                filaExel.add(nombreProducto);
                filaExel.add(fabricante);
                filaExel.add(contenedor);
                filaExel.add(cantidad);
                filaExel.add(precioCompra);
                filaExel.add(precioVenta);
                filaExel.add(fecha);
                for (int a = 0; a < filaExel.size(); a++) {
                    celda = fila.createCell(a);
                    if (a == 3) {
                        celda.setCellValue(Integer.parseInt(filaExel.get(a)));
                    } else if (a == 4 || a == 5) {
                        celda.setCellValue(Double.parseDouble(filaExel.get(a)));
                    } else {
                        celda.setCellValue(filaExel.get(a));
                    }
                }
                this.operacion.setText("operando : " + contador);
                contador++;
            } while (resultado.next());

        }
        String direccionCompleta = "C:\\Users\\zombozo\\Documents\\compras.xls";
        File archivo = new File(direccionCompleta);
        archivoSalida = new FileOutputStream(archivo);
        libro.write(archivoSalida);
        archivoSalida.close();
        JOptionPane.showMessageDialog(rootPane,
                "Creado Correctamente, busque el archivo en la carpeta documentos");
        conexion.close();
    } catch (Exception e) {
        JOptionPane.showMessageDialog(rootPane, "Ocurrio un error 1: " + e);
    }
}