List of usage examples for org.apache.poi.ss.usermodel CellStyle setFont
void setFont(Font font);
From source file:egovframework.rte.fdl.excel.EgovExcelXSSFServiceTest.java
License:Apache License
/** * [Flow #-6] ? : ? ?(?, ? )? /* w w w.j a v a 2 s. c om*/ */ @Test public void testModifyCellAttribute() throws Exception { try { LOGGER.debug("testModifyCellAttribute start...."); StringBuffer sb = new StringBuffer(); sb.append(fileLocation).append("/").append("testModifyCellAttribute.xlsx"); if (EgovFileUtil.isExistsFile(sb.toString())) { EgovFileUtil.delete(new File(sb.toString())); LOGGER.debug("Delete file....{}", sb.toString()); } Workbook wbTmp = new XSSFWorkbook(); wbTmp.createSheet(); // ? ? excelService.createWorkbook(wbTmp, sb.toString()); // ? XSSFWorkbook wb = excelService.loadWorkbook(sb.toString(), new XSSFWorkbook()); LOGGER.debug("testModifyCellAttribute after loadWorkbook...."); Sheet sheet = wb.createSheet("cell test sheet2"); sheet.setColumnWidth((short) 3, (short) 200); // column Width CellStyle cs = wb.createCellStyle(); XSSFFont font = wb.createFont(); font.setFontHeight(16); font.setBoldweight((short) 3); font.setFontName("fixedsys"); cs.setFont(font); cs.setAlignment(XSSFCellStyle.ALIGN_RIGHT); // cell cs.setWrapText(true); for (int i = 0; i < 100; i++) { Row row = sheet.createRow(i); row.setHeight((short) 300); // row? height for (int j = 0; j < 5; j++) { Cell cell = row.createCell(j); cell.setCellValue(new XSSFRichTextString("row " + i + ", cell " + j)); cell.setCellStyle(cs); } } // ? FileOutputStream out = new FileOutputStream(sb.toString()); wb.write(out); out.close(); ////////////////////////////////////////////////////////////////////////// // ? XSSFWorkbook wbT = excelService.loadWorkbook(sb.toString(), new XSSFWorkbook()); Sheet sheetT = wbT.getSheet("cell test sheet2"); LOGGER.debug("getNumCellStyles : {}", wbT.getNumCellStyles()); XSSFCellStyle cs1 = (XSSFCellStyle) wbT.getCellStyleAt((short) (wbT.getNumCellStyles() - 1)); XSSFFont fontT = cs1.getFont(); LOGGER.debug("font getFontHeight : {}", fontT.getFontHeight()); LOGGER.debug("font getBoldweight : {}", fontT.getBoldweight()); LOGGER.debug("font getFontName : {}", fontT.getFontName()); LOGGER.debug("getAlignment : {}", cs1.getAlignment()); LOGGER.debug("getWrapText : {}", cs1.getWrapText()); for (int i = 0; i < 100; i++) { Row row1 = sheetT.getRow(i); for (int j = 0; j < 5; j++) { Cell cell1 = row1.getCell(j); LOGGER.debug("row {}, cell {} : {}", i, j, cell1.getRichStringCellValue()); assertEquals(320, fontT.getFontHeight()); assertEquals(400, fontT.getBoldweight()); LOGGER.debug("fontT.getBoldweight()? ? 400? ?"); assertEquals(XSSFCellStyle.ALIGN_RIGHT, cs1.getAlignment()); assertTrue(cs1.getWrapText()); } } } catch (Exception e) { LOGGER.error(e.toString()); throw new Exception(e); } finally { LOGGER.debug("testModifyCellAttribute end...."); } }
From source file:eionet.cr.util.export.XlsExporter.java
License:Mozilla Public License
/** * exports custom search to XLS format./*from w ww . j a v a 2 s. c om*/ * * @param customSearch * @return * @throws IOException * @throws DAOException */ protected InputStream doExport() throws IOException, DAOException { HSSFWorkbook workbook = new HSSFWorkbook(); sheet = workbook.createSheet("exported data"); // some pretty print with headers CellStyle headerStyle = workbook.createCellStyle(); Font headerFont = workbook.createFont(); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); headerStyle.setFont(headerFont); // output headers HSSFRow headers = sheet.createRow(0); // store width of each column +1 for Uri or Label column columnWidth = new int[getSelectedColumns().size() + 1]; // output Uri or Label column String uriOrLabelColumn = getUriOrLabel(); columnWidth[0] = uriOrLabelColumn.length(); HSSFCell uriOrLabelCell = headers.createCell(0); XlsUtil.setCellValue(uriOrLabelCell, uriOrLabelColumn); uriOrLabelCell.setCellStyle(headerStyle); // output rest of the headers int columnNumber = 1; for (Pair<String, String> columnPair : getSelectedColumns()) { // label is already added to the list of elements if (Predicates.RDFS_LABEL.equals(columnPair.getLeft())) continue; String column = columnPair.getRight() != null ? columnPair.getRight() : columnPair.getLeft(); columnWidth[columnNumber] = column.length(); HSSFCell cell = headers.createCell(columnNumber++); XlsUtil.setCellValue(cell, column); cell.setCellStyle(headerStyle); } sheet.createFreezePane(0, 1); // output serarch results SubjectExportReader reader = new SubjectExportReader(this); doExportQueryAndWriteDataIntoOutput(reader); // set column width for (int i = 0; i < getSelectedColumns().size() + 1; i++) { sheet.setColumnWidth(i, Math.min(256 * columnWidth[i], 256 * 255)); } ByteArrayOutputStream output = new ByteArrayOutputStream(); workbook.write(output); return new ByteArrayInputStream(output.toByteArray()); }
From source file:eu.alpinweiss.filegen.service.impl.GenerateXlsxFileServiceImpl.java
License:Apache License
public void generateExcel(String excelFilename, int rowCount, List<FieldDefinition> fieldDefinitionList, int sheetCount) { long startTime = new Date().getTime(); outputWriterHolder.writeValueInLine("Excel data generation started"); Workbook wb = new SXSSFWorkbook(); try {//from w w w . j av a 2s .c o m CellStyle cs = wb.createCellStyle(); cs.setFillForegroundColor(IndexedColors.LIME.getIndex()); cs.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND); Font f = wb.createFont(); f.setBoldweight(Font.BOLDWEIGHT_BOLD); f.setFontHeightInPoints((short) 12); cs.setFont(f); SXSSFSheet sheet1 = (SXSSFSheet) wb.createSheet("dataSheet"); int columnCount = fieldDefinitionList.size(); Map<Integer, Input2TableInfo> input2TableInfoMap = new LinkedHashMap<>(columnCount); for (int i = 0; i < columnCount; i++) { Input2TableInfo input2TableInfo = new Input2TableInfo(); FieldDefinition fieldDefinition = fieldDefinitionList.get(i); input2TableInfo.setFieldText(fieldDefinition.getFieldName()); input2TableInfo.setFieldDefinition(fieldDefinition); input2TableInfo.initCellStyle(wb); input2TableInfo.initGenerator(); input2TableInfoMap.put(i, input2TableInfo); } if (sheetCount > 1) { CountDownLatch startSignal = new CountDownLatch(1); CountDownLatch doneSignal; doneSignal = new CountDownLatch(sheetCount); ParameterVault parameterVault = new DefaultParameterVault(0, rowCount); SheetProcessor stringProcessorSheet1 = new SheetProcessor(parameterVault, startSignal, doneSignal, cs, sheet1, columnCount, input2TableInfoMap, outputWriterHolder); new Thread(stringProcessorSheet1, "Processor-" + sheetCount).start(); for (int i = 0; i < sheetCount - 1; i++) { SXSSFSheet sheet = (SXSSFSheet) wb.createSheet("dataSheet_" + i); ParameterVault parameterVaultRest = new DefaultParameterVault(i + 1, rowCount); SheetProcessor stringProcessor = new SheetProcessor(parameterVaultRest, startSignal, doneSignal, cs, sheet, columnCount, input2TableInfoMap, outputWriterHolder); new Thread(stringProcessor, "Processor-" + i).start(); } startSignal.countDown(); doneSignal.await(); } else { ParameterVault parameterVault = new DefaultParameterVault(0, rowCount); new SheetProcessor(outputWriterHolder).generateSheetData(parameterVault, cs, sheet1, columnCount, input2TableInfoMap); } outputWriterHolder.writeValueInLine("Excel data generation finished."); long generationTime = new Date().getTime(); outputWriterHolder.writeValueInLine("Time used " + ((generationTime - startTime) / 1000) + " sec"); outputWriterHolder.writeValueInLine("Writing to file."); FileOutputStream fileOut = new FileOutputStream(excelFilename.trim()); wb.write(fileOut); fileOut.close(); long writeTime = new Date().getTime(); outputWriterHolder.writeValueInLine("Time used " + ((writeTime - generationTime) / 1000) + " sec"); outputWriterHolder.writeValueInLine("Total time used " + ((writeTime - startTime) / 1000) + " sec"); outputWriterHolder.writeValueInLine("Done"); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } finally { try { wb.close(); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } } }
From source file:eu.esdihumboldt.hale.io.xls.writer.XLSLookupTableWriter.java
License:Open Source License
/** * @see eu.esdihumboldt.hale.common.core.io.impl.AbstractIOProvider#execute(eu.esdihumboldt.hale.common.core.io.ProgressIndicator, * eu.esdihumboldt.hale.common.core.io.report.IOReporter) *//* w ww . java2s . co m*/ @Override protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException { Workbook workbook; // write xls file if (getContentType().getId().equals("eu.esdihumboldt.hale.io.xls.xls")) { workbook = new HSSFWorkbook(); } // write xlsx file else if (getContentType().getId().equals("eu.esdihumboldt.hale.io.xls.xlsx")) { workbook = new XSSFWorkbook(); } else { reporter.error(new IOMessageImpl("Content type is invalid!", null)); reporter.setSuccess(false); return reporter; } Sheet sheet = workbook.createSheet(); workbook.setSheetName(0, "Lookup table"); Row row = null; Cell cell = null; DataFormat df = workbook.createDataFormat(); // create cell style of the header CellStyle headerStyle = workbook.createCellStyle(); Font headerFont = workbook.createFont(); // use bold font headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); headerStyle.setFont(headerFont); // set a medium border headerStyle.setBorderBottom(CellStyle.BORDER_MEDIUM); // set cell data format to text headerStyle.setDataFormat(df.getFormat("@")); // create cell style CellStyle rowStyle = workbook.createCellStyle(); // set thin border around the cell rowStyle.setBorderBottom(CellStyle.BORDER_THIN); rowStyle.setBorderLeft(CellStyle.BORDER_THIN); rowStyle.setBorderRight(CellStyle.BORDER_THIN); // set cell data format to text rowStyle.setDataFormat(df.getFormat("@")); // display multiple lines rowStyle.setWrapText(true); Map<Value, Value> table = getLookupTable().getTable().asMap(); int rownum = 0; // write header row = sheet.createRow(rownum++); cell = row.createCell(0); cell.setCellValue(getParameter(LookupTableExportConstants.PARAM_SOURCE_COLUMN).as(String.class)); cell.setCellStyle(headerStyle); cell = row.createCell(1); cell.setCellValue(getParameter(LookupTableExportConstants.PARAM_TARGET_COLUMN).as(String.class)); cell.setCellStyle(headerStyle); for (Value key : table.keySet()) { // create a row row = sheet.createRow(rownum); cell = row.createCell(0); cell.setCellValue(key.as(String.class)); cell.setCellStyle(rowStyle); Value entry = table.get(key); cell = row.createCell(1); cell.setCellValue(entry.as(String.class)); cell.setCellStyle(rowStyle); rownum++; } // write file FileOutputStream out = new FileOutputStream(getTarget().getLocation().getPath()); workbook.write(out); out.close(); reporter.setSuccess(true); return reporter; }
From source file:eu.esdihumboldt.hale.io.xls.XLSCellStyles.java
License:Open Source License
/** * @param workbook the workbook of the cell * @return the header cell style/* w w w .j ava2 s .c om*/ */ public static CellStyle getHeaderStyle(Workbook workbook) { CellStyle headerStyle = workbook.createCellStyle(); Font headerFont = workbook.createFont(); DataFormat df = workbook.createDataFormat(); // use bold font headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); headerStyle.setFont(headerFont); // set a medium border headerStyle.setBorderBottom(CellStyle.BORDER_MEDIUM); // set cell data format to text headerStyle.setDataFormat(df.getFormat("@")); return headerStyle; }
From source file:eu.esdihumboldt.hale.io.xls.XLSCellStyles.java
License:Open Source License
/** * @param workbook the workbook of the cell * @param strikeOut true, if cell should be striked out * @return the normal cell style/*ww w . ja va 2s . c o m*/ */ public static CellStyle getNormalStyle(Workbook workbook, boolean strikeOut) { // create cell style CellStyle cellStyle = workbook.createCellStyle(); DataFormat df = workbook.createDataFormat(); // set thin border around the cell cellStyle.setBorderBottom(CellStyle.BORDER_THIN); cellStyle.setBorderLeft(CellStyle.BORDER_THIN); cellStyle.setBorderRight(CellStyle.BORDER_THIN); // set cell data format to text cellStyle.setDataFormat(df.getFormat("@")); // display multiple lines cellStyle.setWrapText(true); if (strikeOut) { // strike out font Font disabledFont = workbook.createFont(); disabledFont.setStrikeout(true); disabledFont.setColor(IndexedColors.GREY_40_PERCENT.getIndex()); cellStyle.setFont(disabledFont); } return cellStyle; }
From source file:eu.esdihumboldt.hale.io.xls.XLSCellStyles.java
License:Open Source License
/** * @param workbook the workbook of the cell * @param strikeOut true, if cell should be striked out * @return the highlighted cell style/*w ww. j a v a2 s . c o m*/ */ public static CellStyle getHighlightedStyle(Workbook workbook, boolean strikeOut) { // create highlight style for type cells CellStyle highlightStyle = workbook.createCellStyle(); DataFormat df = workbook.createDataFormat(); // set thin border around the cell highlightStyle.setBorderBottom(CellStyle.BORDER_THIN); highlightStyle.setBorderLeft(CellStyle.BORDER_THIN); highlightStyle.setBorderRight(CellStyle.BORDER_THIN); // set cell data format to text highlightStyle.setDataFormat(df.getFormat("@")); // display multiple lines highlightStyle.setWrapText(true); highlightStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); highlightStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); if (strikeOut) { Font disabledTypeFont = workbook.createFont(); disabledTypeFont.setStrikeout(true); disabledTypeFont.setColor(IndexedColors.BLACK.getIndex()); highlightStyle.setFont(disabledTypeFont); } return highlightStyle; }
From source file:ExcelFx.FXMLDocumentController.java
private static Map<String, CellStyle> createStyles(Workbook wb) { Map<String, CellStyle> styles = new HashMap<>(); DataFormat df = wb.createDataFormat(); CellStyle styleNormal; CellStyle styleTotal;/*from www . j a v a 2s . co m*/ CellStyle styleHeader; Font font1 = wb.createFont(); font1.setBoldweight(Font.BOLDWEIGHT_NORMAL); Font font2 = wb.createFont(); font2.setBoldweight(Font.BOLDWEIGHT_BOLD); styleNormal = borderedStyleNormal(wb); styleNormal.setFont(font1); styles.put("normal", styleNormal); styleTotal = borderedStyleTotal(wb); styleTotal.setFont(font2); styleTotal.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); styleTotal.setFillPattern(CellStyle.SOLID_FOREGROUND); styles.put("total", styleTotal); styleHeader = borderedStyleHeader(wb); styleHeader.setFont(font1); styleHeader.setRotation((short) 90); styles.put("header", styleHeader); return styles; }
From source file:excelmasivo.ExcelMasivo.java
/** * @param args the command line arguments */// w w w.ja v a2 s . c om public static void main(String[] args) { String driver = "oracle.jdbc.OracleDriver"; String user = "DRKL"; String pass = "DRKL"; String url = "jdbc:oracle:thin:@localhost:1521:XE"; String query = "SELECT * FROM PRODUCTOS ORDER BY TO_NUMBER(SUBSTR(CODIGO_PRODUCTO,7))"; Connection con; Statement st; ResultSet rs; ResultSetMetaData rsm; SXSSFWorkbook libro = new SXSSFWorkbook(); SXSSFSheet hoja = libro.createSheet("Reporte"); SXSSFRow fila; SXSSFCell celda; FileOutputStream out; int x = 0; CellStyle cs = libro.createCellStyle(); cs.getFillForegroundColor(); Font f = libro.createFont(); //f.setBoldweight(Font.BOLDWEIGHT_BOLD); f.setFontHeightInPoints((short) 12); cs.setFont(f); try { Class.forName(driver); con = DriverManager.getConnection(url, user, pass); st = con.createStatement(); rs = st.executeQuery(query); rsm = rs.getMetaData(); while (rs.next()) { //crear la fila fila = hoja.createRow(x++); for (int i = 1; i <= rsm.getColumnCount(); i++) { //recorrer las columnas celda = fila.createCell(i); celda.setCellStyle(cs); celda.setCellValue(rs.getString(i)); //System.out.print(rs.getString(i)); } //System.out.println(); if (x % 50000 == 0) { System.out.println("Se procesaron:" + x); } } out = new FileOutputStream(new File("D:\\java\\Productos_" + GregorianCalendar.MILLISECOND + ".xlsx")); libro.write(out); out.close(); System.out.println("Archivo generado con exito"); } catch (ClassNotFoundException | SQLException | FileNotFoundException ex) { Logger.getLogger(ExcelMasivo.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ExcelMasivo.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.ExporOnlyViagemExcel.java
private void dataTableDados(Workbook wb, Date dataInicio, Date dataFim) throws ParseException { Font fTitulo = wb.createFont(); fTitulo.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fTitulo.setFontHeightInPoints((short) 14); Font fTituloP = wb.createFont(); fTituloP.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fTituloP.setFontHeightInPoints((short) 12); // fTituloP.setStrikeout(true); fTituloP.setUnderline(org.apache.poi.ss.usermodel.Font.U_SINGLE); Font fTituloTabela = wb.createFont(); fTituloTabela.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fTituloTabela.setFontHeightInPoints((short) 8); Font fCorpoTabela = wb.createFont(); fCorpoTabela.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_NORMAL); fCorpoTabela.setFontHeightInPoints((short) 8.5); Font fRodapeTabela = wb.createFont(); fRodapeTabela.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fRodapeTabela.setFontHeightInPoints((short) 8.5); Font fNormal = wb.createFont(); fNormal.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fNormal.setFontHeightInPoints((short) 8.5); CellStyle csTitulo = wb.createCellStyle(); csTitulo.setFont(fTitulo); csTitulo.setAlignment((short) 1); csTitulo.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM); csTitulo.setBorderBottom((short) 0); csTitulo.setBorderTop((short) 0); csTitulo.setBorderRight((short) 0); csTitulo.setBorderLeft((short) 0); csTitulo.setWrapText(true);/* w w w .ja va 2s .c o m*/ CellStyle csTituloP = wb.createCellStyle(); csTituloP.setFont(fTituloP); csTituloP.setAlignment((short) 1); csTituloP.setVerticalAlignment((short) 1); csTituloP.setBorderBottom((short) 0); csTituloP.setBorderTop((short) 0); csTituloP.setBorderRight((short) 0); csTituloP.setBorderLeft((short) 0); csTituloP.setWrapText(true); CellStyle csTituloT = wb.createCellStyle(); csTituloT.setFont(fTituloP); csTituloT.setAlignment((short) 1); csTituloT.setVerticalAlignment((short) 1); csTituloT.setBorderBottom((short) 0); csTituloT.setBorderTop((short) 0); csTituloT.setBorderRight((short) 0); csTituloT.setBorderLeft((short) 0); csTituloT.setWrapText(true); CellStyle csTituloTabela = wb.createCellStyle(); csTituloTabela.setFont(fTituloTabela); csTituloTabela.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabela.setVerticalAlignment((short) 2); csTituloTabela.setBorderBottom((short) 2); csTituloTabela.setBorderTop((short) 2); csTituloTabela.setBorderRight((short) 2); csTituloTabela.setBorderLeft((short) 2); csTituloTabela.setWrapText(true); CellStyle csTituloTabelaNBorder = wb.createCellStyle(); csTituloTabelaNBorder.setFont(fTituloTabela); csTituloTabelaNBorder.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabelaNBorder.setVerticalAlignment((short) 2); csTituloTabelaNBorder.setBorderBottom((short) 2); csTituloTabelaNBorder.setBorderTop((short) 2); csTituloTabelaNBorder.setBorderRight((short) 2); csTituloTabelaNBorder.setBorderLeft((short) 2); csTituloTabelaNBorder.setWrapText(true); CellStyle csCorpoTabela = wb.createCellStyle(); csCorpoTabela.setFont(fCorpoTabela); csCorpoTabela.setAlignment((short) 2); csCorpoTabela.setVerticalAlignment((short) 1); csCorpoTabela.setBorderBottom((short) 1); csCorpoTabela.setBorderTop((short) 1); csCorpoTabela.setBorderRight((short) 1); csCorpoTabela.setBorderLeft((short) 1); csCorpoTabela.setWrapText(true); CellStyle csCorpoTabelaR = wb.createCellStyle(); csCorpoTabelaR.setFont(fCorpoTabela); csCorpoTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csCorpoTabelaR.setVerticalAlignment((short) 1); csCorpoTabelaR.setBorderBottom((short) 1); csCorpoTabelaR.setBorderTop((short) 1); csCorpoTabelaR.setBorderRight((short) 1); csCorpoTabelaR.setBorderLeft((short) 1); csCorpoTabelaR.setWrapText(true); CellStyle csCorpoTabelaL = wb.createCellStyle(); csCorpoTabelaL.setFont(fCorpoTabela); csCorpoTabelaL.setAlignment(CellStyle.ALIGN_LEFT); csCorpoTabelaL.setVerticalAlignment((short) 1); csCorpoTabelaL.setBorderBottom((short) 1); csCorpoTabelaL.setBorderTop((short) 1); csCorpoTabelaL.setBorderRight((short) 1); csCorpoTabelaL.setBorderLeft((short) 1); csCorpoTabelaL.setWrapText(true); CellStyle csRodapeTabela = wb.createCellStyle(); csRodapeTabela.setFont(fRodapeTabela); csRodapeTabela.setAlignment((short) 1); csRodapeTabela.setVerticalAlignment((short) 2); csRodapeTabela.setBorderBottom((short) 2); csRodapeTabela.setBorderTop((short) 2); csRodapeTabela.setBorderRight((short) 2); csRodapeTabela.setBorderLeft((short) 2); csRodapeTabela.setWrapText(true); CellStyle csRodapeTabelaR = wb.createCellStyle(); csRodapeTabelaR.setFont(fRodapeTabela); csRodapeTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csRodapeTabelaR.setVerticalAlignment((short) 2); csRodapeTabelaR.setBorderBottom((short) 2); csRodapeTabelaR.setBorderTop((short) 2); csRodapeTabelaR.setBorderRight((short) 2); csRodapeTabelaR.setBorderLeft((short) 2); csRodapeTabelaR.setWrapText(true); CellStyle csNomal = wb.createCellStyle(); csNomal.setFont(fCorpoTabela); csNomal.setAlignment((short) 1); csNomal.setVerticalAlignment((short) 1); csNomal.setBorderBottom((short) 0); csNomal.setBorderTop((short) 0); csNomal.setBorderRight((short) 0); csNomal.setBorderLeft((short) 0); csNomal.setWrapText(true); int i, p = 0; dataViagem(dataInicio, dataFim); for (Map.Entry<String, ArrayList<HashMap<String, Object>>> data : hasList.entrySet()) { totalSelo = 0f; totalConsumo = 0f; totalTotal = 0f; totalPremio = 0f; totalComissao = 0f; linha = 0; SimpleDateFormat sdfEsp = new SimpleDateFormat("MMMM, yyyy", Locale.ENGLISH); SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy"); String titile = sdfEsp.format(sdf.parse((data.getKey()))).toUpperCase(); Sheet s = wb.createSheet(titile); dataTableTitile(s, titile, csTitulo, csTituloP, csTituloTabelaNBorder); Row r = s.createRow(linha); Cell c = r.createCell(2); for (int j = 0; j < 13; j++) { switch (j) { case 0: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 1, 4); break; case 1: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 2, 6); break; case 2: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 3, 8); break; case 3: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 4, 6); break; case 4: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 5, 6); break; case 5: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 6, 4); break; case 6: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 7, 25); break; case 7: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 8, 10); break; case 8: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 9, 10); break; case 9: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 10, 8); break; case 10: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 11, 8); break; case 11: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 12, 8); break; case 12: createCell(c, r, s, csTituloTabela, linha, linha, funcaoTitulo(j), 13, 8); break; default: break; } } i = 1; for (HashMap<String, Object> hashMap : data.getValue()) { linha++; r = s.createRow(linha); c = r.createCell(2); createCell(c, r, s, csCorpoTabela, linha, linha, (i + ""), 1, 4); createCell(c, r, s, csCorpoTabela, linha, linha, toString(hashMap.get(DATA)), 2, 6); createCell(c, r, s, csCorpoTabela, linha, linha, toString(hashMap.get(NUMEROAPOLICE)), 3, 7); createCell(c, r, s, csCorpoTabela, linha, linha, ConfigDoc.toFormat(toString(hashMap.get(INICIO)), "dd-MM-yyyy", "yyyy-MM-dd"), 4, 6); createCell(c, r, s, csCorpoTabela, linha, linha, ConfigDoc.toFormat(toString(hashMap.get(FIM)), "dd-MM-yyyy", "yyyy-MM-dd"), 5, 6); createCell(c, r, s, csCorpoTabela, linha, linha, toString(hashMap.get(DIAS)), 6, 4); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(hashMap.get(CLIENTE)), 7, 20); createCell(c, r, s, csCorpoTabela, linha, linha, toString(hashMap.get(RECIBO)), 8, 10); createCell(c, r, s, csCorpoTabelaR, linha, linha, toString(hashMap.get(PREMIO)), 9, 10); totalComissao += toFloat(toString(hashMap.get(COMISSAO))); createCell(c, r, s, csCorpoTabelaR, linha, linha, ConfigDoc.toMoeda(toString(hashMap.get(COMISSAO)), ""), 10, 8); totalConsumo += toFloat(toString(hashMap.get(CONSUMO))); createCell(c, r, s, csCorpoTabelaR, linha, linha, ConfigDoc.toMoeda(toString(hashMap.get(CONSUMO)), ""), 11, 8); totalSelo += toFloat(toString(hashMap.get(SELO))); createCell(c, r, s, csCorpoTabelaR, linha, linha, ConfigDoc.toMoeda(toString(hashMap.get(SELO)), ""), 12, 8); totalTotal += toFloat(toString(hashMap.get(TOTAL))); createCell(c, r, s, csCorpoTabelaR, linha, linha, ConfigDoc.toMoeda(toString(hashMap.get(TOTAL)), ""), 13, 8); i++; } linha++; radapeTable(s, csRodapeTabelaR); } }