List of usage examples for org.apache.poi.hssf.usermodel HSSFFont setFontName
public void setFontName(String name)
From source file:Documentos.ClaseAlmacenGeneral.java
private static void createTituloCell(HSSFWorkbook wb, Row row, int column, short halign, short valign, String strContenido) {/*from w w w .j a v a 2 s .co m*/ CreationHelper ch = wb.getCreationHelper(); Cell cell = row.createCell(column); cell.setCellValue(ch.createRichTextString(strContenido)); HSSFFont cellFont = wb.createFont(); cellFont.setFontHeightInPoints((short) 11); cellFont.setFontName(HSSFFont.FONT_ARIAL); cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(halign); cellStyle.setVerticalAlignment(valign); cellStyle.setFont(cellFont); cell.setCellStyle(cellStyle); }
From source file:domain.Excel.java
public void styles() { /*ETIQUETA TABLA */ HSSFFont FontNormal = wb.createFont(); FontNormal.setFontName("Calibri"); FontNormal.setFontHeightInPoints((short) 8); FontNormal.setColor(HSSFColor.BLACK.index); styleCenter = wb.createCellStyle(); styleCenter.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleCenter.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleCenter.setFont(FontNormal); styleRight = wb.createCellStyle(); styleRight.setAlignment(HSSFCellStyle.ALIGN_RIGHT); styleRight.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleRight.setFont(FontNormal);//from w ww. j a v a 2 s. c o m styleleft = wb.createCellStyle(); styleleft.setAlignment(HSSFCellStyle.ALIGN_LEFT); styleleft.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleleft.setFont(FontNormal); styleBorderCompletoMedio = wb.createCellStyle(); styleBorderCompletoMedio.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); styleBorderCompletoMedio.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); styleBorderCompletoMedio.setBorderRight(HSSFCellStyle.BORDER_MEDIUM); styleBorderCompletoMedio.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM); /*Name REPORT*/ HSSFFont FontNameReport = wb.createFont(); FontNameReport.setFontName("Calibri"); FontNameReport.setFontHeightInPoints((short) 16); FontNameReport.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); FontNameReport.setColor(HSSFColor.BROWN.index); styleNameReport = wb.createCellStyle(); styleNameReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleNameReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleNameReport.setFont(FontNameReport); /*DATE REPORT*/ HSSFFont FontDateReport = wb.createFont(); FontDateReport.setFontName("Calibri"); FontDateReport.setFontHeightInPoints((short) 8); FontDateReport.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); FontDateReport.setColor(HSSFColor.BLACK.index); styleDateReport = wb.createCellStyle(); styleDateReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleDateReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleDateReport.setFont(FontDateReport); //Etiqueta parametro HSSFFont FontParametroReport = wb.createFont(); FontParametroReport.setFontName("Calibri"); FontParametroReport.setFontHeightInPoints((short) 8); FontParametroReport.setColor(HSSFColor.BLACK.index); styleParamReport = wb.createCellStyle(); styleParamReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleParamReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); /*TITULO TABLA */ HSSFFont FontTituloTabla = wb.createFont(); FontDateReport.setFontName("Calibri"); FontDateReport.setFontHeightInPoints((short) 8); FontDateReport.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); FontDateReport.setColor(HSSFColor.BLACK.index); styleTituloTabla = wb.createCellStyle(); styleTituloTabla.setAlignment(HSSFCellStyle.ALIGN_LEFT); styleTituloTabla.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleTituloTabla.setFont(FontDateReport); /*ETIQUETA TABLA */ HSSFFont FontEtiquetaTabla = wb.createFont(); FontEtiquetaTabla.setFontName("Calibri"); FontEtiquetaTabla.setFontHeightInPoints((short) 8); FontEtiquetaTabla.setColor(HSSFColor.BLACK.index); styleEtiquetaTabla = wb.createCellStyle(); styleEtiquetaTabla.setAlignment(HSSFCellStyle.ALIGN_LEFT); styleEtiquetaTabla.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleEtiquetaTabla.setFont(FontEtiquetaTabla); /*ETIQUETA GANANCIA DE PESO */ HSSFFont FontGananciaPeso = wb.createFont(); FontGananciaPeso.setFontName("Calibri"); FontGananciaPeso.setFontHeightInPoints((short) 12); FontGananciaPeso.setColor(HSSFColor.BLACK.index); styleGananciaPeso = wb.createCellStyle(); styleGananciaPeso.setAlignment(HSSFCellStyle.ALIGN_LEFT); styleGananciaPeso.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleGananciaPeso.setFont(FontGananciaPeso); }
From source file:domain.Excel.java
public void reporteSesionPeso() { // cargarLogo(); sheet.addMergedRegion(CellRangeAddress.valueOf("A1:E1")); sheet.addMergedRegion(CellRangeAddress.valueOf("A2:E2")); sheet.addMergedRegion(CellRangeAddress.valueOf("A3:E4")); /*Name REPORT*/ HSSFFont FontNameReport = wb.createFont(); FontNameReport.setFontName("Calibri"); FontNameReport.setFontHeightInPoints((short) 11); FontNameReport.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); FontNameReport.setColor(HSSFColor.DARK_RED.index); HSSFCellStyle styleNameReport = wb.createCellStyle(); styleNameReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleNameReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleNameReport.setFont(FontNameReport); Row row = sheet.createRow(0);//from ww w . j av a 2s .com Cell cell = row.createCell(0); cell.setCellValue("REPORTE DE SESIONES POR PESOS"); cell.setCellStyle(styleNameReport); /**/ /*DATE REPORT*/ HSSFFont FontDateReport = wb.createFont(); FontDateReport.setFontName("Calibri"); FontDateReport.setFontHeightInPoints((short) 10); FontDateReport.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); FontDateReport.setColor(HSSFColor.BLACK.index); HSSFCellStyle styleDateReport = wb.createCellStyle(); styleDateReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleDateReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleDateReport.setFont(FontDateReport); row = sheet.createRow(1); cell = row.createCell(0); cell.setCellValue("FECHA DE REPORTE: " + formatoDateTime.format(new Date())); cell.setCellStyle(styleDateReport); /*Etiqueta parametro*/ HSSFFont FontParametroReport = wb.createFont(); FontParametroReport.setFontName("Calibri"); FontParametroReport.setFontHeightInPoints((short) 9); FontParametroReport.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL); FontParametroReport.setColor(HSSFColor.BLACK.index); HSSFCellStyle styleParamReport = wb.createCellStyle(); styleParamReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleParamReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleParamReport.setFont(FontParametroReport); row = sheet.createRow(2); cell = row.createCell(0); String etiqueta_parametro = ""; switch (tipo) { case 1: etiqueta_parametro = "Sesion de dia " + formatoDate.format(fecha_ini); break; case 2: etiqueta_parametro = "Sesiones del " + formatoDate.format(fecha_ini) + " al " + formatoDate.format(fecha_fin); break; case 3: etiqueta_parametro = "Sesiones del animal " + animal.arete_visual; break; } cell.setCellValue(etiqueta_parametro); cell.setCellStyle(styleParamReport); /**/ sheet.createRow(5).createCell(0).setCellValue("Arete Visual"); sheet.getRow(5).createCell(1).setCellValue("Arete Electronico"); sheet.getRow(5).createCell(2).setCellValue("Fecha"); sheet.getRow(5).createCell(3).setCellValue("Peso"); sheet.getRow(5).createCell(4).setCellValue("Corral"); sheet.setColumnWidth(0, 16 * Unidad); sheet.setColumnWidth(1, 16 * Unidad); sheet.setColumnWidth(2, 16 * Unidad); sheet.setColumnWidth(3, 16 * Unidad); sheet.setColumnWidth(4, 16 * Unidad); SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting(); //Condition 1: Cell Value Is greater than 70 (Blue Fill) ConditionalFormattingRule rule1 = sheetCF .createConditionalFormattingRule(CFRuleRecord.ComparisonOperator.GT, "1000"); PatternFormatting fill1 = rule1.createPatternFormatting(); fill1.setFillBackgroundColor(IndexedColors.DARK_RED.index); fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND); //Condition 2: Cell Value Is less than 50 (Green Fill) ConditionalFormattingRule rule2 = sheetCF .createConditionalFormattingRule(CFRuleRecord.ComparisonOperator.LT, "50"); PatternFormatting fill2 = rule2.createPatternFormatting(); fill2.setFillBackgroundColor(IndexedColors.DARK_RED.index); fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND); FontFormatting font = rule1.createFontFormatting(); font.setFontStyle(false, true); font.setFontColorIndex(IndexedColors.WHITE.index); CellRangeAddress[] regions = { CellRangeAddress.valueOf("A6:E6") }; sheetCF.addConditionalFormatting(regions, rule1, rule2); Integer fila_inicial = 6; for (int i = 0; i < this.t_tabla.getRowCount(); i++) { sheet.createRow(fila_inicial + i).createCell(0).setCellValue(t_tabla.getValueAt(i, 1).toString()); sheet.getRow(fila_inicial + i).getCell(0).setCellStyle(styleCenter); for (int j = 1; j < 5; j++) { sheet.getRow(fila_inicial + i).createCell(j).setCellValue(t_tabla.getValueAt(i, j + 1).toString()); sheet.getRow(fila_inicial + i).getCell(j).setCellStyle(styleCenter); } sheet.getRow(fila_inicial + i).getCell(3) .setCellValue(Double.parseDouble(t_tabla.getValueAt(i, 4).toString())); sheet.getRow(fila_inicial + i).getCell(3).setCellStyle(styleRight); } cargarLogo(); }
From source file:domain.Excel.java
private void reporteSesionMedicina() { sheet.addMergedRegion(CellRangeAddress.valueOf("A1:I1")); sheet.addMergedRegion(CellRangeAddress.valueOf("A2:I2")); sheet.addMergedRegion(CellRangeAddress.valueOf("A3:I4")); /*Name REPORT*/ HSSFFont FontNameReport = wb.createFont(); FontNameReport.setFontName("Calibri"); FontNameReport.setFontHeightInPoints((short) 11); FontNameReport.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); FontNameReport.setColor(HSSFColor.DARK_RED.index); HSSFCellStyle styleNameReport = wb.createCellStyle(); styleNameReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleNameReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleNameReport.setFont(FontNameReport); Row row = sheet.createRow(0);/*from www . ja v a 2 s . co m*/ Cell cell = row.createCell(0); cell.setCellValue("REPORTE DE SESIONES POR MEDICAMENTOS"); cell.setCellStyle(styleNameReport); /**/ /*DATE REPORT*/ HSSFFont FontDateReport = wb.createFont(); FontDateReport.setFontName("Calibri"); FontDateReport.setFontHeightInPoints((short) 10); FontDateReport.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); FontDateReport.setColor(HSSFColor.BLACK.index); HSSFCellStyle styleDateReport = wb.createCellStyle(); styleDateReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleDateReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleDateReport.setFont(FontDateReport); row = sheet.createRow(1); cell = row.createCell(0); cell.setCellValue("FECHA DE REPORTE: " + formatoDateTime.format(new Date())); cell.setCellStyle(styleDateReport); /*Etiqueta parametro*/ HSSFFont FontParametroReport = wb.createFont(); FontParametroReport.setFontName("Calibri"); FontParametroReport.setFontHeightInPoints((short) 9); FontParametroReport.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL); FontParametroReport.setColor(HSSFColor.BLACK.index); HSSFCellStyle styleParamReport = wb.createCellStyle(); styleParamReport.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleParamReport.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); styleParamReport.setFont(FontParametroReport); row = sheet.createRow(2); cell = row.createCell(0); String etiqueta_parametro = ""; switch (tipo) { case 1: etiqueta_parametro = "Sesion de dia " + formatoDate.format(fecha_ini); break; case 2: etiqueta_parametro = "Sesiones del " + formatoDate.format(fecha_ini) + " al " + formatoDate.format(fecha_fin); break; case 3: etiqueta_parametro = "Sesiones del animal " + animal.arete_visual; break; } cell.setCellValue(etiqueta_parametro); cell.setCellStyle(styleParamReport); /**/ sheet.createRow(5).createCell(0).setCellValue("Arete Visual"); sheet.getRow(5).createCell(1).setCellValue("Arete Electronico"); sheet.getRow(5).createCell(2).setCellValue("Codigo"); sheet.getRow(5).createCell(3).setCellValue("Medicamento"); sheet.getRow(5).createCell(4).setCellValue("Fecha"); sheet.getRow(5).createCell(5).setCellValue("Corral"); sheet.getRow(5).createCell(6).setCellValue("Dosis"); sheet.getRow(5).createCell(7).setCellValue("Costo"); sheet.getRow(5).createCell(8).setCellValue("Importe"); sheet.setColumnWidth(0, 15 * Unidad); sheet.setColumnWidth(1, 20 * Unidad); sheet.setColumnWidth(2, 15 * Unidad); sheet.setColumnWidth(3, 20 * Unidad); sheet.setColumnWidth(4, 20 * Unidad); sheet.setColumnWidth(5, 20 * Unidad); sheet.setColumnWidth(6, 15 * Unidad); sheet.setColumnWidth(7, 15 * Unidad); sheet.setColumnWidth(8, 15 * Unidad); SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting(); //Condition 1: Cell Value Is greater than 70 (Blue Fill) ConditionalFormattingRule rule1 = sheetCF .createConditionalFormattingRule(CFRuleRecord.ComparisonOperator.GT, "1000"); PatternFormatting fill1 = rule1.createPatternFormatting(); fill1.setFillBackgroundColor(IndexedColors.DARK_RED.index); fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND); //Condition 2: Cell Value Is less than 50 (Green Fill) ConditionalFormattingRule rule2 = sheetCF .createConditionalFormattingRule(CFRuleRecord.ComparisonOperator.LT, "50"); PatternFormatting fill2 = rule2.createPatternFormatting(); fill2.setFillBackgroundColor(IndexedColors.DARK_RED.index); fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND); FontFormatting font = rule1.createFontFormatting(); font.setFontStyle(false, true); font.setFontColorIndex(IndexedColors.WHITE.index); CellRangeAddress[] regions = { CellRangeAddress.valueOf("A6:I6") }; sheetCF.addConditionalFormatting(regions, rule1, rule2); Integer fila_inicial = 6; for (int i = 0; i < this.t_tabla.getRowCount(); i++) { agregarValor(fila_inicial + i, 0, t_tabla.getValueAt(i, 1).toString(), styleCenter); for (int j = 0; j < 9; j++) { agregarValor(fila_inicial + i, j, t_tabla.getValueAt(i, j + 1).toString(), styleCenter); } } cargarLogo(); }
From source file:egovframework.rte.fdl.excel.EgovExcelSXSSFServiceTest.java
License:Apache License
/** * [Flow #-6] ? : ? ?(?, ? )? // w ww. ja v a 2 s. c o m */ @Test public void testModifyCellAttribute() throws Exception { try { log.debug("testModifyCellAttribute start...."); StringBuffer sb = new StringBuffer(); sb.append(fileLocation).append("/").append("testModifyCellAttribute.xls"); if (EgovFileUtil.isExistsFile(sb.toString())) { EgovFileUtil.delete(new File(sb.toString())); log.debug("Delete file...." + sb.toString()); } HSSFWorkbook wbTmp = new HSSFWorkbook(); wbTmp.createSheet(); // ? ? excelService.createWorkbook(wbTmp, sb.toString()); // ? HSSFWorkbook wb = excelService.loadWorkbook(sb.toString()); log.debug("testModifyCellAttribute after loadWorkbook...."); HSSFSheet sheet = wb.createSheet("cell test sheet2"); // sheet.setColumnWidth((short) 3, (short) 200); // column Width HSSFCellStyle cs = wb.createCellStyle(); HSSFFont font = wb.createFont(); font.setFontHeight((short) 16); font.setBoldweight((short) 3); font.setFontName("fixedsys"); cs.setFont(font); cs.setAlignment(HSSFCellStyle.ALIGN_RIGHT); // cell cs.setWrapText(true); for (int i = 0; i < 100; i++) { HSSFRow row = sheet.createRow(i); // row.setHeight((short)300); // row? height for (int j = 0; j < 5; j++) { HSSFCell cell = row.createCell(j); cell.setCellValue(new HSSFRichTextString("row " + i + ", cell " + j)); cell.setCellStyle(cs); } } // ? FileOutputStream out = new FileOutputStream(sb.toString()); wb.write(out); out.close(); ////////////////////////////////////////////////////////////////////////// // ? HSSFWorkbook wbT = excelService.loadWorkbook(sb.toString()); HSSFSheet sheetT = wbT.getSheet("cell test sheet2"); log.debug("getNumCellStyles : " + wbT.getNumCellStyles()); HSSFCellStyle cs1 = wbT.getCellStyleAt((short) (wbT.getNumCellStyles() - 1)); HSSFFont fontT = cs1.getFont(wbT); log.debug("font getFontHeight : " + fontT.getFontHeight()); log.debug("font getBoldweight : " + fontT.getBoldweight()); log.debug("font getFontName : " + fontT.getFontName()); log.debug("getAlignment : " + cs1.getAlignment()); log.debug("getWrapText : " + cs1.getWrapText()); for (int i = 0; i < 100; i++) { HSSFRow row1 = sheetT.getRow(i); for (int j = 0; j < 5; j++) { HSSFCell cell1 = row1.getCell(j); log.debug("row " + i + ", cell " + j + " : " + cell1.getRichStringCellValue()); assertEquals(16, fontT.getFontHeight()); assertEquals(3, fontT.getBoldweight()); assertEquals(HSSFCellStyle.ALIGN_RIGHT, cs1.getAlignment()); assertTrue(cs1.getWrapText()); } } } catch (Exception e) { log.error(e.toString()); throw new Exception(e); } finally { log.debug("testModifyCellAttribute end...."); } }
From source file:eionet.gdem.conversion.excel.writer.ExcelConversionHandler.java
License:Mozilla Public License
/** * Adds style to workbook.//w w w.java 2 s . c om * @param style Style */ private void addStyleToWorkbook(ExcelStyleIF style) { HSSFFont font = wb.createFont(); // Font Size eg.12 short height = style.getFontSize(); if (height > 0) { font.setFontHeightInPoints(height); } // Font Name eg.Arial String font_name = style.getFontName(); if (font_name != null) { font.setFontName(font_name); } // Italic font.setItalic(style.getItalic()); // Font Weight eg.bold short weight = style.getFontWeight(); font.setBoldweight(weight); // Fonts are set into a style so create a new one to use. HSSFCellStyle HSSFStyle = wb.createCellStyle(); HSSFStyle.setFont(font); // Text alignment eg.center short align = style.getTextAlign(); HSSFStyle.setAlignment(align); style.setWorkbookIndex(HSSFStyle.getIndex()); }
From source file:es.jamisoft.comun.io.excel.ExcelGenerator.java
License:Apache License
/** * Este mtodo asigna el formato a los caracteres. * * @param wb Objeto Excel./*from w w w.ja v a 2s . c o m*/ * @param cellStyle Estilo de celda para crearl formato a los caracteres. * @param fillFontColor Color que se asignara a los cartares. */ private void createFontCell(HSSFWorkbook wb, HSSFCellStyle cellStyle, short fillFontColor) { // create instance of HSSFCellStyle HSSFFont fontHead = wb.createFont(); // Create Font Header fontHead.setFontHeightInPoints(ep.getSizeFont()); if (ep.getFontName() != null) { fontHead.setFontName(ep.getFontName()); } fontHead.setColor(fillFontColor); // Fonts are set into a style so create a new one to use. cellStyle.setFont(fontHead); }
From source file:Excel.InformeArticulos.java
public void GenerarInforme(ArrayList listadoClientes) throws SQLException { HSSFWorkbook libro = new HSSFWorkbook(); HSSFSheet hoja = libro.createSheet("Listado de Articulos"); ArrayList listadoPorSucursal = new ArrayList(); Editables edi = new Articulos(); /*//from w w w .j av a2 s . c o m * GENERAR LAS SIGUIENTES HOJAS * 1- DETALLE DE MOVIMIENTOS DE CAJA - LEE EN MOVIMIENTOS CAJA INDENTIFICANDO EL TIPO DE MOVIMIENTO, USUARIOS Y * NUMERO DE CAJA * 2- DETALLE DE ARTICULOS VENDIDOS: LISTADO DE MOVIEMIENTOS DE ARTICULOS, CON USUARIOS Y CAJA * 3- DETALLE DE GASTOS : MOVIMIENTOS DE CAJA DETALLANDO LOS GASTOS * */ String ttx = "celda numero :"; HSSFRow fila = null; HSSFCell celda; HSSFCell celda1; HSSFCell celda2; HSSFCell celda3; HSSFCell celda4; HSSFCell celda5; HSSFCell celda6; HSSFCell celda7; HSSFCell celda8; HSSFCell celda9; HSSFCell celda10; HSSFCell celda11; HSSFFont fuente = libro.createFont(); //fuente.setFontHeight((short)21); fuente.setFontName(fuente.FONT_ARIAL); fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); String form = null; HSSFCellStyle titulo = libro.createCellStyle(); Iterator iCli = listadoClientes.listIterator(); Articulos cliente = new Articulos(); titulo.setFont(fuente); //titulo.setFillBackgroundColor((short)22); titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //for(int a=0;a < 100;a++){ int col = 0; int a = 0; if (a == 0) { fila = hoja.createRow(a); celda = fila.createCell(0); celda.setCellStyle(titulo); celda.setCellValue("Codigo"); celda1 = fila.createCell(1); celda1.setCellStyle(titulo); celda1.setCellValue("Descripcion"); celda2 = fila.createCell(2); celda2.setCellStyle(titulo); celda2.setCellValue("Stock"); celda3 = fila.createCell(3); celda3.setCellStyle(titulo); celda3.setCellValue("Stock Mnimo"); celda4 = fila.createCell(4); celda4.setCellStyle(titulo); celda4.setCellValue("Costo"); celda5 = fila.createCell(5); celda5.setCellStyle(titulo); celda5.setCellValue("Precio de Venta"); celda6 = fila.createCell(6); celda6.setCellStyle(titulo); celda6.setCellValue("Servicio"); } while (iCli.hasNext()) { cliente = (Articulos) iCli.next(); a++; //col=rs.getInt("tipoMovimiento"); switch (col) { case 1: break; default: break; } fila = hoja.createRow(a); celda = fila.createCell(0); ttx = ttx; celda.setCellType(HSSFCell.CELL_TYPE_STRING); celda.setCellValue(cliente.getCodigoAsignado()); celda1 = fila.createCell(1); ttx = ttx; celda1.setCellType(HSSFCell.CELL_TYPE_STRING); celda1.setCellValue(cliente.getDescripcionArticulo()); celda2 = fila.createCell(2); celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda2.setCellValue(cliente.getStockActual()); celda3 = fila.createCell(3); celda3.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda3.setCellValue(cliente.getStockMinimo()); celda4 = fila.createCell(4); celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda4.setCellValue(cliente.getPrecioDeCosto()); celda5 = fila.createCell(5); //celda5.setCellFormula(rs.getString("observaciones")); celda5.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda5.setCellValue(cliente.getPrecioUnitarioNeto()); //celda5.setCellValue(rs.getDate("fecha")); celda6 = fila.createCell(6); //celda5.setCellFormula(rs.getString("observaciones")); celda6.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda6.setCellValue(cliente.getPrecioServicio()); listadoPorSucursal = edi.ListarPorSucursal(cliente); Iterator il = listadoPorSucursal.listIterator(); Articulos arr = new Articulos(); int cont = 0; while (il.hasNext()) { arr = (Articulos) il.next(); cont++; switch (cont) { case 1: celda7 = fila.createCell(7); celda7.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda7.setCellValue(arr.getCantidad()); break; case 2: celda8 = fila.createCell(8); celda8.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda8.setCellValue(arr.getCantidad()); break; case 3: celda9 = fila.createCell(9); celda9.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda9.setCellValue(arr.getCantidad()); break; case 4: celda10 = fila.createCell(10); celda10.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda10.setCellValue(arr.getCantidad()); break; } } } //texto+="\r\n"; String ruta = "C://Informes//listadoDeArticulos.xls"; try { FileOutputStream elFichero = new FileOutputStream(ruta); try { libro.write(elFichero); elFichero.close(); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + ruta); } catch (IOException ex) { Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Excel.InformeDiarioStock.java
public void GenerrarInformeStock() throws SQLException { HSSFWorkbook libro = new HSSFWorkbook(); HSSFSheet hoja = libro.createSheet("Articulos"); /*//from w w w. j a v a2 s .co m * GENERAR LAS SIGUIENTES HOJAS * 1- DETALLE DE MOVIMIENTOS DE CAJA - LEE EN MOVIMIENTOS CAJA INDENTIFICANDO EL TIPO DE MOVIMIENTO, USUARIOS Y * NUMERO DE CAJA * 2- DETALLE DE ARTICULOS VENDIDOS: LISTADO DE MOVIEMIENTOS DE ARTICULOS, CON USUARIOS Y CAJA * 3- DETALLE DE GASTOS : MOVIMIENTOS DE CAJA DETALLANDO LOS GASTOS * */ HSSFSheet hoja1 = libro.createSheet("Movimientos"); HSSFSheet hoja2 = libro.createSheet("Movimientos Caja"); String ttx = "celda numero :"; HSSFRow fila = null; HSSFCell celda; HSSFCell celda1; HSSFCell celda2; HSSFCell celda3; HSSFCell celda4; HSSFCell celda5; HSSFCell celda6; HSSFCell celda7; HSSFCell celda8; HSSFCell celda9; HSSFCell celda10; HSSFFont fuente = libro.createFont(); //fuente.setFontHeight((short)21); fuente.setFontName(fuente.FONT_ARIAL); fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); String form = null; //String sql="select id,nombre,(select sum(movimientosarticulos.cantidad) from movimientosarticulos where movimientosarticulos.idarticulo=articulos.id and movimientosarticulos.numerodeposito="+Inicio.deposito.getNumero()+")as stock,(select sum(movimientosarticulos.cantidad) from movimientosarticulos where movimientosarticulos.idcaja="+Inicio.caja.getNumero()+" and movimientosarticulos.idarticulo=articulos.id)as cantidadVendida from articulos"; String sql = "select *,(select articulos.NOMBRE from articulos where articulos.ID=movimientosarticulos.idArticulo)as descripcion from movimientosarticulos where idcaja=" + Inicio.caja.getNumero(); System.out.println(sql); Transaccionable tra = new ConeccionLocal(); ResultSet rs = tra.leerConjuntoDeRegistros(sql); HSSFCellStyle titulo = libro.createCellStyle(); titulo.setFont(fuente); //titulo.setFillBackgroundColor((short)22); titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //for(int a=0;a < 100;a++){ int col = 0; int a = 0; if (a == 0) { fila = hoja.createRow(a); celda = fila.createCell(0); celda.setCellStyle(titulo); celda.setCellValue("id"); celda1 = fila.createCell(1); celda1.setCellStyle(titulo); celda1.setCellValue("nombre"); celda2 = fila.createCell(2); celda2.setCellStyle(titulo); celda2.setCellValue("Unidades Vendidas"); celda3 = fila.createCell(3); celda3.setCellStyle(titulo); celda3.setCellValue("Fecha"); } while (rs.next()) { a++; //col=rs.getInt("tipoMovimiento"); switch (col) { case 1: break; default: break; } fila = hoja.createRow(a); celda = fila.createCell(0); ttx = ttx; Double anterior = 0.00; Double actual = 0.00; Double vendido = 0.00; celda.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda.setCellValue(rs.getInt("idArticulo")); celda1 = fila.createCell(1); ttx = ttx; celda1.setCellType(HSSFCell.CELL_TYPE_STRING); celda1.setCellValue(rs.getString("descripcion")); celda2 = fila.createCell(2); vendido = (rs.getDouble("cantidad")) * -1; //actual=rs.getDouble("stock"); celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda2.setCellValue(vendido); celda3 = fila.createCell(3); //vendido=(rs.getDouble("cantidadVendida")) * -1; celda3.setCellType(HSSFCell.CELL_TYPE_STRING); celda3.setCellValue(rs.getString("fecha")); } //rs.close(); // hoja 2 form = null; sql = "SELECT id,cantidad,preciodecosto,preciodeventa,precioservicio,fecha,numerocomprobante,(select listcli.RAZON_SOCI from listcli where listcli.codMmd=movimientosarticulos.numeroCliente limit 0,1)as nombreC,(select articulos.NOMBRE from articulos where articulos.ID=movimientosarticulos.idArticulo limit 0,1)as descA,(select usuarios.nombre from usuarios where usuarios.numero=movimientosarticulos.numeroUsuario limit 0,1) as nombreU FROM movimientosarticulos where tipoMovimiento =1 and idcaja=" + Inicio.caja.getNumero(); //System.out.println(sql); //tra=new Conecciones(); rs = tra.leerConjuntoDeRegistros(sql); //HSSFCellStyle titulo=libro.createCellStyle(); titulo.setFont(fuente); //titulo.setFillBackgroundColor((short)22); titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //for(int a=0;a < 100;a++){ col = 0; a = 0; if (a == 0) { fila = hoja1.createRow(a); celda = fila.createCell(0); celda.setCellStyle(titulo); celda.setCellValue("Cajero"); celda1 = fila.createCell(1); celda1.setCellStyle(titulo); celda1.setCellValue("Descripcion Articulo"); celda2 = fila.createCell(2); celda2.setCellStyle(titulo); celda2.setCellValue("Cantidad"); celda3 = fila.createCell(3); celda3.setCellStyle(titulo); celda3.setCellValue("Precio de Costo"); celda4 = fila.createCell(4); celda4.setCellStyle(titulo); celda4.setCellValue("Precio de Venta"); celda5 = fila.createCell(5); celda5.setCellStyle(titulo); celda5.setCellValue("Fecha"); celda6 = fila.createCell(6); celda6.setCellStyle(titulo); celda6.setCellValue("Precio de Servicio"); celda7 = fila.createCell(7); celda7.setCellStyle(titulo); celda7.setCellValue("comprobante"); celda8 = fila.createCell(8); celda8.setCellStyle(titulo); celda8.setCellValue("Cliente"); celda9 = fila.createCell(9); celda9.setCellStyle(titulo); celda9.setCellValue("Total"); celda10 = fila.createCell(10); celda10.setCellStyle(titulo); celda10.setCellValue("idMovimiento"); } while (rs.next()) { a++; //col=rs.getInt("tipoMovimiento"); switch (col) { case 1: break; default: break; } fila = hoja1.createRow(a); celda = fila.createCell(0); ttx = ttx; celda.setCellType(HSSFCell.CELL_TYPE_STRING); celda.setCellValue(rs.getString("nombreU")); celda1 = fila.createCell(1); ttx = ttx; celda1.setCellType(HSSFCell.CELL_TYPE_STRING); celda1.setCellValue(rs.getString("descA")); celda2 = fila.createCell(2); celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda2.setCellValue(rs.getDouble("cantidad")); celda3 = fila.createCell(3); celda3.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda3.setCellValue(rs.getDouble("precioDeCosto")); celda4 = fila.createCell(4); celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda4.setCellValue(rs.getDouble("precioDeVenta")); celda5 = fila.createCell(5); //celda5.setCellFormula(rs.getString("observaciones")); celda5.setCellType(HSSFCell.CELL_TYPE_STRING); celda5.setCellValue(" " + rs.getDate("fecha")); //celda5.setCellValue(rs.getDate("fecha")); celda6 = fila.createCell(6); celda6.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda6.setCellValue(rs.getDouble("precioServicio")); celda7 = fila.createCell(7); celda7.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda7.setCellValue(rs.getInt("numeroComprobante")); celda8 = fila.createCell(8); celda8.setCellType(HSSFCell.CELL_TYPE_STRING); celda8.setCellValue(rs.getString("nombreC")); celda9 = fila.createCell(9); celda9.setCellType(HSSFCell.CELL_TYPE_NUMERIC); Double tto = 0.00; tto = rs.getDouble("precioServicio") + rs.getDouble("precioDeVenta"); celda9.setCellValue(tto); celda10 = fila.createCell(10); celda10.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda10.setCellValue(rs.getInt("id")); } form = null; sql = "SELECT *,(select usuarios.nombre from usuarios where usuarios.numero=movimientoscaja.numeroUsuario)as nombreUsuario,(select listcli.RAZON_SOCI from listcli where listcli.id=movimientoscaja.idCliente)as nombreCliente,(select tipocomprobantes.descripcion from tipocomprobantes where tipocomprobantes.numero=movimientoscaja.tipoComprobante)as nombreComprobante,(select tipomovimientos.DESCRIPCION from tipomovimientos where tipomovimientos.ID=movimientoscaja.tipoMovimiento)as nombreMov FROM movimientoscaja where idcaja=" + Inicio.caja.getNumero() + " order by id"; //System.out.println(sql); //tra=new Conecciones(); rs = tra.leerConjuntoDeRegistros(sql); //HSSFCellStyle titulo=libro.createCellStyle(); titulo.setFont(fuente); //titulo.setFillBackgroundColor((short)22); titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //for(int a=0;a < 100;a++){ col = 0; a = 0; if (a == 0) { fila = hoja2.createRow(a); celda = fila.createCell(0); celda.setCellStyle(titulo); celda.setCellValue("Cajero"); celda1 = fila.createCell(1); celda1.setCellStyle(titulo); celda1.setCellValue("Cliente"); celda2 = fila.createCell(2); celda2.setCellStyle(titulo); celda2.setCellValue("Comprobante Numero"); celda3 = fila.createCell(3); celda3.setCellStyle(titulo); celda3.setCellValue("Tipo Comprobante"); celda4 = fila.createCell(4); celda4.setCellStyle(titulo); celda4.setCellValue("Monto"); celda5 = fila.createCell(5); celda5.setCellStyle(titulo); celda5.setCellValue("Fecha"); celda6 = fila.createCell(6); celda6.setCellStyle(titulo); celda6.setCellValue("Tipo de Movimiento"); celda7 = fila.createCell(7); celda7.setCellStyle(titulo); celda7.setCellValue("Condicion"); celda8 = fila.createCell(8); celda8.setCellStyle(titulo); celda8.setCellValue("idMovimiento"); } while (rs.next()) { a++; //col=rs.getInt("tipoMovimiento"); switch (col) { case 1: break; default: break; } fila = hoja2.createRow(a); celda = fila.createCell(0); ttx = ttx; celda.setCellType(HSSFCell.CELL_TYPE_STRING); celda.setCellValue(rs.getString("nombreUsuario")); celda1 = fila.createCell(1); ttx = ttx; celda1.setCellType(HSSFCell.CELL_TYPE_STRING); celda1.setCellValue(rs.getString("nombreCliente")); celda2 = fila.createCell(2); celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda2.setCellValue(rs.getInt("numeroComprobante")); celda3 = fila.createCell(3); celda3.setCellType(HSSFCell.CELL_TYPE_STRING); celda3.setCellValue(rs.getString("nombreComprobante")); celda4 = fila.createCell(4); celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda4.setCellValue(rs.getDouble("monto")); celda5 = fila.createCell(5); //celda5.setCellFormula(rs.getString("observaciones")); celda5.setCellType(HSSFCell.CELL_TYPE_STRING); celda5.setCellValue(" " + rs.getDate("fecha")); //celda5.setCellValue(rs.getDate("fecha")); celda6 = fila.createCell(6); celda6.setCellType(HSSFCell.CELL_TYPE_STRING); celda6.setCellValue(rs.getString("nombreMov")); celda7 = fila.createCell(7); String pagado = "PAGADO"; if (rs.getInt("pagado") == 0 && rs.getInt("tipoMovimiento") == 1) pagado = "CTA CTE"; celda7.setCellType(HSSFCell.CELL_TYPE_STRING); celda7.setCellValue(pagado); celda8 = fila.createCell(8); celda8.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda8.setCellValue(rs.getInt("id")); } rs.close(); //texto+="\r\n"; String ruta = "C://Informes//" + Inicio.fechaDia + "_" + Inicio.usuario.getNombre() + " - informeDeStock.xls"; String nombree = Inicio.fechaDia + "_" + Inicio.usuario.getNombre() + " - informeDeStock.xls"; try { FileOutputStream elFichero = new FileOutputStream(ruta); try { libro.write(elFichero); elFichero.close(); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + ruta); Mail mail = new Mail(); String mailRecepcion = Propiedades.getCORREOCIERREDECAJA(); mail.setDetalleListado(nombree); mail.setDireccionFile(ruta); mail.setAsunto("Informe de cierre de caja " + Inicio.fechaDia + " Sucursal: " + Propiedades.getNOMBRECOMERCIO()); mail.enviarMailRepartoCargaCompleta(mailRecepcion); } catch (IOException ex) { Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex); } catch (MessagingException ex) { Logger.getLogger(InformeDiarioStock.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, "NO SE HA PODIDO ENVIAR EL MENSAJE MOTIVO :" + ex); } } catch (FileNotFoundException ex) { Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex); } sql = "select id,nombre,precio,servicio,(select sum(movimientosarticulos.cantidad) from movimientosarticulos where movimientosarticulos.idcaja=" + Inicio.caja.getNumero() + " and movimientosarticulos.idarticulo=articulos.id)as cantidadVendida from articulos order by cantidadVendida desc"; rs = tra.leerConjuntoDeRegistros(sql); System.out.println(sql); Transaccionable tt = new Conecciones(); String sql1; Double cantVend; while (rs.next()) { cantVend = rs.getDouble("cantidadVendida"); if (cantVend < 0) { //sql1="insert into movimientosarticulosF (tipoMovimiento,idArticulo,cantidad,numeroDeposito,tipoComprobante,numeroCliente,numerousuario,precioDeVenta,precioServicio,idcaja) values (1,"+rs.getInt("id")+",floor("+rs.getDouble("cantidadVendida")+" * 0.1),"+Inicio.deposito.getNumero()+",1,1,"+Inicio.usuario.getNumeroId()+","+rs.getDouble("precio")+","+rs.getDouble("servicio")+","+Inicio.caja.getNumero()+")"; //System.out.println(sql1); //tt.guardarRegistro(sql1); } } }
From source file:Excel.InformesClientes.java
public void GenerarInforme(ArrayList listadoClientes, String desde, String hasta) throws SQLException { HSSFWorkbook libro = new HSSFWorkbook(); HSSFSheet hoja = libro.createSheet("Saldos de Clientes"); HSSFSheet hoja1 = libro.createSheet("Detalle de Saldos"); /*/* w w w .j a v a 2s.c o m*/ * GENERAR LAS SIGUIENTES HOJAS * 1- DETALLE DE MOVIMIENTOS DE CAJA - LEE EN MOVIMIENTOS CAJA INDENTIFICANDO EL TIPO DE MOVIMIENTO, USUARIOS Y * NUMERO DE CAJA * 2- DETALLE DE ARTICULOS VENDIDOS: LISTADO DE MOVIEMIENTOS DE ARTICULOS, CON USUARIOS Y CAJA * 3- DETALLE DE GASTOS : MOVIMIENTOS DE CAJA DETALLANDO LOS GASTOS * */ String ttx = "celda numero :"; HSSFRow fila = null; HSSFCell celda; HSSFCell celda1; HSSFCell celda2; HSSFCell celda3; HSSFCell celda4; HSSFCell celda5; HSSFCell celda6; HSSFCell celda7; HSSFCell celda8; HSSFFont fuente = libro.createFont(); //fuente.setFontHeight((short)21); fuente.setFontName(fuente.FONT_ARIAL); fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); String form = null; String sql = ""; System.out.println(sql); Transaccionable tra = new Conecciones(); ResultSet rs = null; HSSFCellStyle titulo = libro.createCellStyle(); Iterator iCli = listadoClientes.listIterator(); ClientesTango cliente = new ClientesTango(); titulo.setFont(fuente); //titulo.setFillBackgroundColor((short)22); titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //for(int a=0;a < 100;a++){ int col = 0; int a = 0; if (a == 0) { fila = hoja.createRow(a); celda = fila.createCell(0); celda.setCellStyle(titulo); celda.setCellValue("Cod. Cliente"); celda1 = fila.createCell(1); celda1.setCellStyle(titulo); celda1.setCellValue("Nombre"); celda2 = fila.createCell(2); celda2.setCellStyle(titulo); celda2.setCellValue("Direccion"); celda3 = fila.createCell(3); celda3.setCellStyle(titulo); celda3.setCellValue("Telfono"); celda4 = fila.createCell(4); celda4.setCellStyle(titulo); celda4.setCellValue("Cupo de Crdito"); celda5 = fila.createCell(5); celda5.setCellStyle(titulo); celda5.setCellValue("Saldo"); } while (iCli.hasNext()) { cliente = (ClientesTango) iCli.next(); a++; //col=rs.getInt("tipoMovimiento"); switch (col) { case 1: break; default: break; } fila = hoja.createRow(a); celda = fila.createCell(0); ttx = ttx; celda.setCellType(HSSFCell.CELL_TYPE_STRING); celda.setCellValue(cliente.getCodigoCliente()); celda1 = fila.createCell(1); ttx = ttx; celda1.setCellType(HSSFCell.CELL_TYPE_STRING); celda1.setCellValue(cliente.getRazonSocial()); celda2 = fila.createCell(2); celda2.setCellType(HSSFCell.CELL_TYPE_STRING); celda2.setCellValue(cliente.getDireccion()); celda3 = fila.createCell(3); celda3.setCellType(HSSFCell.CELL_TYPE_STRING); celda3.setCellValue(cliente.getTelefono()); celda4 = fila.createCell(4); celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda4.setCellValue(cliente.getCupoDeCredito()); celda5 = fila.createCell(5); //celda5.setCellFormula(rs.getString("observaciones")); celda5.setCellType(HSSFCell.CELL_TYPE_NUMERIC); if (cliente.getSaldo() != null) { celda5.setCellValue(cliente.getSaldo()); } else { celda5.setCellValue(0.00); } //celda5.setCellValue(rs.getDate("fecha")); } /* * segunda hoja */ Busquedas bus = new ClientesTango(); sql = "select numeroProveedor,fecha,monto,numeroComprobante,idUsuario,idCaja,(select tipomovimientos.descripcion from tipomovimientos where tipomovimientos.ID=movimientosclientes.tipoComprobante)as tipocomprobante1,idSucursal,(select listcli.razon_soci from listcli where listcli.codmmd=numeroProveedor)as nombreP from movimientosclientes where numeroProveedor > 1 and fecha between '" + desde + "' and '" + hasta + "' group by numeroComprobante,tipoComprobante order by numeroProveedor,fecha"; System.out.println(sql); //fuente.setFontHeight((short)21); fuente.setFontName(fuente.FONT_ARIAL); fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); form = null; //String sql="SELECT *,(select proveedores.nombre from proveedores where proveedores.numero=movimientosproveedores.numeroProveedor)as nombreP,if(pagado=0,'pendiente','pagado')as estado FROM movimientosproveedores where fecha between '"+desde+"' and '"+hasta+"'"; //System.out.println(sql); //tra=new Conecciones(); rs = tra.leerConjuntoDeRegistros(sql); titulo.setFont(fuente); //titulo.setFillBackgroundColor((short)22); titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //for(int a=0;a < 100;a++){ col = 0; a = 0; if (a == 0) { fila = hoja1.createRow(a); celda = fila.createCell(0); celda.setCellStyle(titulo); celda.setCellValue("Cliente"); celda1 = fila.createCell(1); celda1.setCellStyle(titulo); celda1.setCellValue("Sucursal"); celda2 = fila.createCell(2); celda2.setCellStyle(titulo); celda2.setCellValue("Fecha"); celda3 = fila.createCell(3); celda3.setCellStyle(titulo); celda3.setCellValue("Monto"); celda4 = fila.createCell(4); celda4.setCellStyle(titulo); celda4.setCellValue("Caja Numero"); celda5 = fila.createCell(5); celda5.setCellStyle(titulo); celda5.setCellValue("tipo de comprobante"); } while (rs.next()) { a++; //col=rs.getInt("tipoMovimiento"); switch (col) { case 1: break; default: break; } fila = hoja1.createRow(a); celda = fila.createCell(0); ttx = ttx; celda.setCellType(HSSFCell.CELL_TYPE_STRING); celda.setCellValue(rs.getString("nombreP")); celda1 = fila.createCell(1); ttx = ttx; celda1.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda1.setCellValue(rs.getInt("idSucursal")); celda2 = fila.createCell(2); celda2.setCellType(HSSFCell.CELL_TYPE_STRING); celda2.setCellValue(" " + rs.getString("fecha")); celda3 = fila.createCell(3); celda3.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda3.setCellValue(rs.getDouble("monto")); celda4 = fila.createCell(4); celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC); celda4.setCellValue(rs.getInt("idCaja")); celda5 = fila.createCell(5); celda5.setCellType(HSSFCell.CELL_TYPE_STRING); //if(rs.getInt("tipoComprobante")==11){ //celda5.setCellValue("Recibo de Pago"); //}else{ celda5.setCellValue(rs.getString("tipocomprobante1")); //} } rs.close(); //texto+="\r\n"; String ruta = "C://Informes//" + desde + "_" + hasta + "_informeDeClientes.xls"; try { FileOutputStream elFichero = new FileOutputStream(ruta); try { libro.write(elFichero); elFichero.close(); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + ruta); } catch (IOException ex) { Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex); } }