List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook createSheet
@Override
public HSSFSheet createSheet(String sheetname)
From source file:common.PoiExcelHelper.java
/** * * @param exportMapDatas ?/* ww w .j av a2 s .c o m*/ * @param columnsExplain ? * @param sheetName * @param outFile ? * @return * @throws FileNotFoundException * @throws IOException */ public static boolean productExcelFile(List<Map<String, String>> exportMapDatas, Map<String, String> columnsExplain, String sheetName, File outFile) throws FileNotFoundException, IOException { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(sheetName); //set columnTitle int rownum = 1, cellnum = 0; Set<String> keysSet = columnsExplain.keySet(); Row columnRowTitle = sheet.createRow(0); for (String key : keysSet) { Cell columnCellTitle = columnRowTitle.createCell(cellnum++); columnCellTitle.setCellValue(columnsExplain.get(key)); } for (Map<String, String> exportMapData : exportMapDatas) { Row sheetRow = sheet.createRow(rownum++); cellnum = 0; for (String key : keysSet) { Cell cell = sheetRow.createCell(cellnum++); cell.setCellValue(exportMapData.get(key)); } } FileOutputStream out = new FileOutputStream(outFile); workbook.write(out); out.close(); return true; }
From source file:control.listaEquipos.java
private boolean generaExcel(String path) { // Se crea el libro HSSFWorkbook libro = new HSSFWorkbook(); // Se crea una hoja dentro del libro HSSFSheet hoja = libro.createSheet("Equipos"); // Se crea una fila dentro de la hoja HSSFRow fila = hoja.createRow(0);/*w ww . j a v a 2s.com*/ // Se crea una celda dentro de la fila HSSFCell celda = fila.createCell((short) 0); HSSFRichTextString texto = new HSSFRichTextString("Id "); celda.setCellValue(texto); celda = fila.createCell((short) 1); texto = new HSSFRichTextString("Nombre"); celda.setCellValue(texto); celda = fila.createCell((short) 2); texto = new HSSFRichTextString("Categoria"); celda.setCellValue(texto); celda = fila.createCell((short) 3); texto = new HSSFRichTextString("Accesorios"); celda.setCellValue(texto); celda = fila.createCell((short) 4); texto = new HSSFRichTextString("Descripcion"); celda.setCellValue(texto); celda = fila.createCell((short) 5); texto = new HSSFRichTextString("Marca"); celda.setCellValue(texto); celda = fila.createCell((short) 6); texto = new HSSFRichTextString("Estado"); celda.setCellValue(texto); int nr = 1; Object[][] tabla = this.getTableData(tabEquipo); for (Object[] o : tabla) { fila = hoja.createRow(nr); int i = 0; for (Object e : o) { celda = fila.createCell((short) i); if (i <= 6) { if (e != null) { texto = new HSSFRichTextString((String) e.toString()); } else { texto = new HSSFRichTextString(""); } celda.setCellValue(texto); } i++; } nr++; } // Se salva el libro. try { FileOutputStream elFichero = new FileOutputStream(path); libro.write(elFichero); elFichero.close(); } catch (Exception e) { e.printStackTrace(); } return true; }
From source file:Controlador.ControladorCargueMasivo.java
public static HSSFWorkbook obtenerExcel(DataModel contenidoCeldas, DataModel cabecerasCeldas, String nombreHoja) {/*from www . jav a 2 s . co m*/ HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); HSSFSheet hssfSheet = hssfWorkbook.createSheet(nombreHoja); int numeroFila = 0; int numeroColumna = 0; HSSFRow hssfRow = hssfSheet.createRow(numeroFila++); HSSFCellStyle hssfCellStyleCabecera = hssfWorkbook.createCellStyle(); hssfCellStyleCabecera.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); hssfCellStyleCabecera.setFillBackgroundColor(new HSSFColor.BLACK().getIndex()); HSSFFont hssfFont = hssfWorkbook.createFont(); hssfFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); hssfFont.setColor(HSSFColor.WHITE.index); hssfCellStyleCabecera.setFont(hssfFont); String columnaCabecera; HSSFCell hssfCell = null; List cabecerasExcel = (List) cabecerasCeldas.getWrappedData(); for (int i = 0; i < cabecerasExcel.size(); i++) { columnaCabecera = (String) cabecerasExcel.get(i); hssfCell = hssfRow.createCell((short) numeroColumna++); hssfCell.setCellValue(columnaCabecera); hssfCell.setCellStyle(hssfCellStyleCabecera); } List contenidoExcel = (List) contenidoCeldas.getWrappedData(); List fila = null; Object valor; for (int i = 0; i < contenidoExcel.size(); i++) { fila = (List) contenidoExcel.get(i); hssfRow = hssfSheet.createRow(numeroFila++); numeroColumna = 0; for (int x = 0; x < fila.size(); x++) { valor = fila.get(x); hssfCell = hssfRow.createCell((short) numeroColumna++); hssfCell.setCellValue((String) valor); } } return hssfWorkbook; }
From source file:Controlador.HSSFCreate.java
/** Processes requests for both HTTP GET and POST methods. * @param request servlet request//from w w w . j a v a 2s.c o m * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/vnd.ms-excel"); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("new sheet"); Map<String, Object[]> data = new HashMap<String, Object[]>(); data.put("1", new Object[] { "Emp No.", "Name", "Salary" }); data.put("2", new Object[] { 1d, "John", 1500000d }); data.put("3", new Object[] { 2d, "Sam", 800000d }); data.put("4", new Object[] { 3d, "Dean", 700000d }); Set<String> keyset = data.keySet(); int rownum = 0; for (String key : keyset) { Row row = sheet.createRow(rownum++); Object[] 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); } } // Write the output OutputStream out = response.getOutputStream(); wb.write(out); out.close(); }
From source file:Controlador.HSSFCreateAeronave.java
/** * Processes requests for both HTTP GET and POST methods. * * @param request servlet request/*from ww w . j a v a2s. c o m*/ * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, URISyntaxException { response.setContentType("application/vnd.ms-excel"); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("new sheet"); Aeronaves a = new Aeronaves(); ArrayList<Aeronave> aeronaves = (ArrayList<Aeronave>) a.findAll(); Map<String, Object[]> data = new HashMap<String, Object[]>(); data.put("0", new Object[] { "id Aeronave", "Nombre" }); for (int i = 0; i < aeronaves.size(); i++) { String j = "" + (i + 1); data.put(j, new Object[] { "" + aeronaves.get(i).getIdAeronave(), String.copyValueOf(aeronaves.get(i).getNombre()) }); } Set<String> keyset = data.keySet(); int rownum = 0; for (String key : keyset) { Row row = sheet.createRow(rownum++); Object[] 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); } } } // Write the output OutputStream out = response.getOutputStream(); wb.write(out); out.close(); }
From source file:controladores.controladorPrincipal.java
public boolean generarReporte() { try {//ww w.ja v a2 s.co m modeloCobranzas cobranza = new modeloCobranzas(); Object[][] facturas = cobranza.listarFacturadasGestion(); String file = "Reporte_cobranza_" + formatDate.format(new Date()) + ".xls"; HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("Folio"); rowhead.createCell(1).setCellValue("Rut"); rowhead.createCell(2).setCellValue("Razn social"); rowhead.createCell(3).setCellValue("Fecha emisin"); rowhead.createCell(4).setCellValue("Das emisin"); rowhead.createCell(5).setCellValue("Neto"); rowhead.createCell(6).setCellValue("Iva"); rowhead.createCell(7).setCellValue("Total"); rowhead.createCell(8).setCellValue("Forma de pago"); rowhead.createCell(9).setCellValue("Medio de pago"); rowhead.createCell(10).setCellValue("Abono"); rowhead.createCell(11).setCellValue("Monto abono"); rowhead.createCell(12).setCellValue("Saldo"); rowhead.createCell(13).setCellValue("Contacto"); rowhead.createCell(14).setCellValue("Telfono"); rowhead.createCell(15).setCellValue("N de gestiones"); rowhead.createCell(16).setCellValue("Tipo gestin"); rowhead.createCell(17).setCellValue("Resultado"); rowhead.createCell(18).setCellValue("Fecha gestin"); rowhead.createCell(19).setCellValue("Observaciones"); int i = 1; for (Object[] fac : facturas) { rowhead = sheet.createRow(i); i++; rowhead.createCell(0).setCellValue(fac[0].toString()); rowhead.createCell(1).setCellValue(fac[1].toString()); rowhead.createCell(2).setCellValue(fac[2].toString()); rowhead.createCell(3).setCellValue(fac[3].toString()); rowhead.createCell(4).setCellValue(fac[4].toString()); rowhead.createCell(5).setCellValue(fac[5].toString()); rowhead.createCell(6).setCellValue(fac[6].toString()); rowhead.createCell(7).setCellValue(fac[7].toString()); rowhead.createCell(8).setCellValue(fac[8].toString()); rowhead.createCell(9).setCellValue(fac[9].toString()); rowhead.createCell(10).setCellValue(fac[10].toString()); rowhead.createCell(11).setCellValue(fac[11].toString()); rowhead.createCell(12).setCellValue(fac[12].toString()); rowhead.createCell(13).setCellValue(fac[13].toString()); rowhead.createCell(14).setCellValue(fac[14].toString()); rowhead.createCell(15).setCellValue(fac[15].toString()); rowhead.createCell(16).setCellValue(fac[16].toString()); rowhead.createCell(17).setCellValue(fac[17].toString()); rowhead.createCell(18).setCellValue(fac[18].toString()); rowhead.createCell(19).setCellValue(fac[19].toString()); FileOutputStream fileOut; fileOut = new FileOutputStream(file); workbook.write(fileOut); fileOut.close(); } } catch (IOException ex) { Logger.getLogger(controladorPrincipal.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); System.out.println(ex.getMessage()); return false; } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); e.printStackTrace(); return false; } JOptionPane.showMessageDialog(null, "Reporte generado con xito", "Operacin exitosa", JOptionPane.INFORMATION_MESSAGE); return true; }
From source file:controladores.controladorPrincipal.java
public boolean generarReporteTrabajador() { DateFormat perDate = new SimpleDateFormat("MMMM-yyyy"); DateFormat numDate = new SimpleDateFormat("yyyy-MM"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, 1);/*from w ww.j a v a 2 s . c o m*/ cal.set(Calendar.DATE, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); String mes = "" + (cal.get(Calendar.MONTH) - 1); String per = perDate.format(new Date()); String fec = numDate.format(new Date()); String fecIn = "2017-" + mes + "-26"; String fecFin = fec + "-25"; // System.out.println(fecIn + " " + fecFin); NumberFormat FORMAT = NumberFormat.getCurrencyInstance(); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); try { String path = "Reporte trabajadores-" + per; File dir = new File(path); dir.mkdir(); modeloEmpleados empleado = new modeloEmpleados(); Object[] ruts = empleado.listarRutEmpleados(); int numEmp = ruts.length; for (int i = 0; i < numEmp; i++) { String file = path + "/Reporte_trabajador_" + ruts[i] + "_" + formatDate.format(new Date()) + ".xls"; Object[][] ots = empleado.obtenerReporteEmpleados(ruts[i].toString(), fecIn, fecFin); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("GRUAS HORQUILLA SANTA TERESITA F.M.LTDA"); rowhead = sheet.createRow(1); rowhead.createCell(3).setCellValue("1 Fecha de informe: " + formatDate.format(new Date())); rowhead = sheet.createRow(2); rowhead.createCell(3).setCellValue("Servicios de operador " + formatDate2.format(new Date())); rowhead = sheet.createRow(4); rowhead.createCell(0).setCellValue("O.T."); rowhead.createCell(1).setCellValue("FECHA."); rowhead.createCell(2).setCellValue("CLIENTE"); // rowhead.createCell(3).setCellValue("O.T."); // rowhead.createCell(4).setCellValue("O.T."); rowhead.createCell(5).setCellValue("SALE"); rowhead.createCell(6).setCellValue("TERMINA"); rowhead.createCell(7).setCellValue("OFICINA"); rowhead.createCell(8).setCellValue("HORAS EXTRA"); rowhead.createCell(8).setCellValue("HORAS ARRIENDO"); rowhead = sheet.createRow(5); rowhead.createCell(0).setCellValue("*** " + ruts[i].toString()); int j = 0; for (Object[] ot : ots) { rowhead = sheet.createRow(j + 6); rowhead.createCell(0).setCellValue(ot[2].toString()); rowhead.createCell(1).setCellValue(ot[3].toString()); rowhead.createCell(2).setCellValue(ot[4].toString()); // rowhead.createCell(3).setCellValue(ot[3].toString()); // rowhead.createCell(4).setCellValue(ot[4].toString()); rowhead.createCell(5).setCellValue(ot[5].toString()); rowhead.createCell(6).setCellValue(ot[6].toString()); rowhead.createCell(7).setCellValue(ot[7].toString()); rowhead.createCell(8).setCellValue("0"); rowhead.createCell(8).setCellValue(ot[9].toString()); j++; } FileOutputStream fileOut; fileOut = new FileOutputStream(file); workbook.write(fileOut); fileOut.close(); } } catch (IOException ex) { ex.printStackTrace(); Logger.getLogger(controladorPrincipal.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); return false; } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); return false; } JOptionPane.showMessageDialog(null, "Reporte generado con xito", "Operacin exitosa", JOptionPane.INFORMATION_MESSAGE); return true; }
From source file:controladores.controladorPrincipal.java
public boolean generarReporteTrabajador(String year, String month) { DateFormat perDate = new SimpleDateFormat("MMMM-yyyy"); DateFormat numDate = new SimpleDateFormat("yyyy-MM"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, 1);/*from w w w. java 2s .com*/ cal.set(Calendar.DATE, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); String mes = "" + (Integer.parseInt(month) - 1); // String per = perDate.format(new Date()); String per = month + "-" + year; String fec = numDate.format(new Date()); String fecIn = "2017-" + mes + "-26"; String fecFin = year + "-" + month + "-25"; // System.out.println(fecIn + " " + fecFin); NumberFormat FORMAT = NumberFormat.getCurrencyInstance(); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); try { String path = "Reporte trabajadores-" + per; File dir = new File(path); dir.mkdir(); modeloEmpleados empleado = new modeloEmpleados(); Object[] ruts = empleado.listarRutEmpleados(); int numEmp = ruts.length; for (int i = 0; i < numEmp; i++) { String file = path + "/Reporte_trabajador_" + ruts[i] + "_" + formatDate.format(new Date()) + ".xls"; Object[][] ots = empleado.obtenerReporteEmpleados(ruts[i].toString(), fecIn, fecFin); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("GRUAS HORQUILLA SANTA TERESITA F.M.LTDA"); rowhead = sheet.createRow(1); rowhead.createCell(3).setCellValue("1 Fecha de informe: " + formatDate.format(new Date())); rowhead = sheet.createRow(2); rowhead.createCell(3).setCellValue("Servicios de operador " + formatDate2.format(new Date())); rowhead = sheet.createRow(4); rowhead.createCell(0).setCellValue("O.T."); rowhead.createCell(1).setCellValue("FECHA."); rowhead.createCell(2).setCellValue("CLIENTE"); // rowhead.createCell(3).setCellValue("O.T."); // rowhead.createCell(4).setCellValue("O.T."); rowhead.createCell(5).setCellValue("SALE"); rowhead.createCell(6).setCellValue("TERMINA"); rowhead.createCell(7).setCellValue("OFICINA"); rowhead.createCell(8).setCellValue("HORAS EXTRA"); rowhead.createCell(8).setCellValue("HORAS ARRIENDO"); rowhead = sheet.createRow(5); rowhead.createCell(0).setCellValue("*** " + ruts[i].toString()); int j = 0; for (Object[] ot : ots) { rowhead = sheet.createRow(j + 6); rowhead.createCell(0).setCellValue(ot[2].toString()); rowhead.createCell(1).setCellValue(ot[3].toString()); rowhead.createCell(2).setCellValue(ot[4].toString()); // rowhead.createCell(3).setCellValue(ot[3].toString()); // rowhead.createCell(4).setCellValue(ot[4].toString()); rowhead.createCell(5).setCellValue(ot[5].toString()); rowhead.createCell(6).setCellValue(ot[6].toString()); rowhead.createCell(7).setCellValue(ot[7].toString()); rowhead.createCell(8).setCellValue("0"); rowhead.createCell(8).setCellValue(ot[9].toString()); j++; } FileOutputStream fileOut; fileOut = new FileOutputStream(file); workbook.write(fileOut); fileOut.close(); } } catch (IOException ex) { ex.printStackTrace(); Logger.getLogger(controladorPrincipal.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); return false; } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); return false; } JOptionPane.showMessageDialog(null, "Reporte generado con xito", "Operacin exitosa", JOptionPane.INFORMATION_MESSAGE); return true; }
From source file:controladores4.controladorReportes.java
public void generarReporteClientes() { Thread runnable = new Thread() { public void run() { modeloFacturas rutas = new modeloFacturas(); String per = perDate.format(new Date()); String fec = numDate.format(new Date()); NumberFormat FORMAT = NumberFormat.getCurrencyInstance(); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); try { String path = "Reportes clientes"; File dir = new File(path); dir.mkdir();// w ww . ja va 2s .com modeloClientes clientes = new modeloClientes(); Object[][] data = clientes.listarReporteClientes(); int numClientes = data.length; String file = path + "/Reporte clientes - " + per + ".xls"; HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("GRUAS HORQUILLA SANTA TERESITA F.M.LTDA"); rowhead = sheet.createRow(1); rowhead.createCell(3).setCellValue("1 Fecha de informe: " + formatDate.format(new Date())); rowhead = sheet.createRow(2); rowhead = sheet.createRow(4); rowhead.createCell(0).setCellValue("RUT"); rowhead.createCell(1).setCellValue("RAZN SOCIAL"); rowhead.createCell(2).setCellValue("GIRO"); rowhead.createCell(3).setCellValue("TELFONO"); rowhead.createCell(4).setCellValue("CELULAR"); rowhead.createCell(5).setCellValue("CORREO"); rowhead.createCell(6).setCellValue("DIRECCIN"); rowhead.createCell(7).setCellValue("REGIN"); rowhead.createCell(8).setCellValue("CIUDAD"); rowhead.createCell(9).setCellValue("COMUNA"); rowhead.createCell(10).setCellValue("OBSERVACIONES"); rowhead.createCell(11).setCellValue("CONTACTO"); rowhead = sheet.createRow(5); int j = 0; for (Object[] cliente : data) { rowhead = sheet.createRow(j + 6); rowhead.createCell(0).setCellValue(cliente[0].toString()); rowhead.createCell(1).setCellValue(cliente[1].toString()); rowhead.createCell(2).setCellValue(cliente[2].toString()); rowhead.createCell(3).setCellValue(cliente[3].toString()); rowhead.createCell(4).setCellValue(cliente[4].toString()); rowhead.createCell(5).setCellValue(cliente[5].toString()); rowhead.createCell(6).setCellValue(cliente[6].toString()); rowhead.createCell(7).setCellValue(cliente[7].toString()); rowhead.createCell(8).setCellValue(cliente[8].toString()); rowhead.createCell(9).setCellValue(cliente[9].toString()); rowhead.createCell(10).setCellValue(cliente[10].toString()); rowhead.createCell(11).setCellValue(cliente[11].toString()); j++; } FileOutputStream fileOut; fileOut = new FileOutputStream(file); workbook.write(fileOut); fileOut.close(); } catch (IOException ex) { ex.printStackTrace(); Logger.getLogger(controladorPrincipal.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); } JOptionPane.showMessageDialog(null, "Reporte clientes generado con xito", "Operacin exitosa", JOptionPane.INFORMATION_MESSAGE); } }; runnable.start(); }
From source file:controladores4.controladorReportes.java
public void generarReporteGruas() { Thread runnable = new Thread() { public void run() { modeloFacturas rutas = new modeloFacturas(); String per = perDate.format(new Date()); String fec = numDate.format(new Date()); NumberFormat FORMAT = NumberFormat.getCurrencyInstance(); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); try { String path = "Reportes gruas"; File dir = new File(path); dir.mkdir();//w ww . ja v a2 s. c o m modeloGruas gruas = new modeloGruas(); Object[][] data = gruas.listarReporteGruas(); int numGruas = data.length; String file = path + "/Reporte gruas - " + per + ".xls"; HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("GRUAS HORQUILLA SANTA TERESITA F.M.LTDA"); rowhead = sheet.createRow(1); rowhead.createCell(3).setCellValue("1 Fecha de informe: " + formatDate.format(new Date())); rowhead = sheet.createRow(4); rowhead.createCell(0).setCellValue("PATENTE"); rowhead.createCell(1).setCellValue("AO"); rowhead.createCell(2).setCellValue("DESCRIPCIN"); rowhead.createCell(3).setCellValue("MARCA"); rowhead.createCell(4).setCellValue("MODELO"); rowhead.createCell(5).setCellValue("TONELAJE"); rowhead.createCell(6).setCellValue("PESO"); rowhead.createCell(7).setCellValue("TIPO NEUM?TICOS"); rowhead.createCell(8).setCellValue("TIPO NEUM?TICOS 2"); rowhead.createCell(9).setCellValue("NMERO DE CHASIS"); rowhead.createCell(10).setCellValue("TIPO DE COMBUSTIBLE"); rowhead.createCell(11).setCellValue("M?STIL"); rowhead.createCell(12).setCellValue("ALTURA M?STIL"); rowhead.createCell(13).setCellValue("ANCHO"); rowhead.createCell(14).setCellValue("LARGO"); rowhead.createCell(15).setCellValue("LARGO UAS"); rowhead.createCell(16).setCellValue("ALTURA LEVANTE"); rowhead.createCell(17).setCellValue("MEDIDA NEUM?TICOS DELANTEROS"); rowhead.createCell(18).setCellValue("MEDIDA NEUM?TICOS TRASEROS"); rowhead.createCell(19).setCellValue("NMERO DE MOTOR"); rowhead.createCell(20).setCellValue("NMERO DE SERIE"); rowhead.createCell(21).setCellValue("FECHA REVISIN TCNICA"); rowhead.createCell(22).setCellValue("FECHA LTIMA MANTENCIN"); rowhead.createCell(23).setCellValue("KM/H LTIMA MANTENCIN"); rowhead.createCell(24).setCellValue("FECHA DE BAJA"); rowhead.createCell(25).setCellValue("OBSERVACIONES"); rowhead.createCell(26).setCellValue("FECHA DE INGRESO"); rowhead.createCell(27).setCellValue("HORMETRO"); rowhead = sheet.createRow(5); int j = 0; for (Object[] grua : data) { rowhead = sheet.createRow(j + 6); rowhead.createCell(0).setCellValue(grua[0].toString()); rowhead.createCell(1).setCellValue(grua[1].toString()); rowhead.createCell(2).setCellValue(grua[2].toString()); rowhead.createCell(3).setCellValue(grua[3].toString()); rowhead.createCell(4).setCellValue(grua[4].toString()); rowhead.createCell(5).setCellValue(grua[5].toString()); rowhead.createCell(6).setCellValue(grua[6].toString()); rowhead.createCell(7).setCellValue(grua[7].toString()); rowhead.createCell(8).setCellValue(grua[8].toString()); rowhead.createCell(9).setCellValue(grua[9].toString()); rowhead.createCell(10).setCellValue(grua[10].toString()); rowhead.createCell(11).setCellValue(grua[11].toString()); rowhead.createCell(12).setCellValue(grua[12].toString()); rowhead.createCell(13).setCellValue(grua[13].toString()); rowhead.createCell(14).setCellValue(grua[14].toString()); rowhead.createCell(15).setCellValue(grua[15].toString()); rowhead.createCell(16).setCellValue(grua[16].toString()); rowhead.createCell(17).setCellValue(grua[17].toString()); rowhead.createCell(18).setCellValue(grua[18].toString()); rowhead.createCell(19).setCellValue(grua[19].toString()); rowhead.createCell(20).setCellValue(grua[20].toString()); rowhead.createCell(21).setCellValue(grua[21].toString()); rowhead.createCell(22).setCellValue(grua[22].toString()); rowhead.createCell(23).setCellValue(grua[23].toString()); rowhead.createCell(24).setCellValue(grua[24].toString()); rowhead.createCell(25).setCellValue(grua[25].toString()); rowhead.createCell(26).setCellValue(grua[26].toString()); rowhead.createCell(27).setCellValue(grua[27].toString()); j++; } FileOutputStream fileOut; fileOut = new FileOutputStream(file); workbook.write(fileOut); fileOut.close(); } catch (IOException ex) { ex.printStackTrace(); Logger.getLogger(controladorPrincipal.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR", JOptionPane.INFORMATION_MESSAGE); } JOptionPane.showMessageDialog(null, "Reporte gras generado con xito", "Operacin exitosa", JOptionPane.INFORMATION_MESSAGE); } }; runnable.start(); }