List of usage examples for org.apache.poi.ss.usermodel Font setFontHeightInPoints
void setFontHeightInPoints(short height);
From source file:it.eng.spagobi.engines.qbe.crosstable.exporter.CrosstabXLSExporter.java
License:Mozilla Public License
public CellStyle buildDataCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_RIGHT); cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER); String cellBGColor = (String) this.getProperty(PROPERTY_CELL_BACKGROUND_COLOR); logger.debug("Cell background color : " + cellBGColor); short backgroundColorIndex = cellBGColor != null ? IndexedColors.valueOf(cellBGColor).getIndex() : IndexedColors.valueOf(DEFAULT_CELL_BACKGROUND_COLOR).getIndex(); cellStyle.setFillForegroundColor(backgroundColorIndex); cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); cellStyle.setBorderBottom(CellStyle.BORDER_THIN); cellStyle.setBorderLeft(CellStyle.BORDER_THIN); cellStyle.setBorderRight(CellStyle.BORDER_THIN); cellStyle.setBorderTop(CellStyle.BORDER_THIN); String bordeBorderColor = (String) this.getProperty(PROPERTY_CELL_BORDER_COLOR); logger.debug("Cell border color : " + bordeBorderColor); short borderColorIndex = bordeBorderColor != null ? IndexedColors.valueOf(bordeBorderColor).getIndex() : IndexedColors.valueOf(DEFAULT_CELL_BORDER_COLOR).getIndex(); cellStyle.setLeftBorderColor(borderColorIndex); cellStyle.setRightBorderColor(borderColorIndex); cellStyle.setBottomBorderColor(borderColorIndex); cellStyle.setTopBorderColor(borderColorIndex); Font font = sheet.getWorkbook().createFont(); Short cellFontSize = (Short) this.getProperty(PROPERTY_CELL_FONT_SIZE); logger.debug("Cell font size : " + cellFontSize); short cellFontSizeShort = cellFontSize != null ? cellFontSize.shortValue() : DEFAULT_CELL_FONT_SIZE; font.setFontHeightInPoints(cellFontSizeShort); String fontName = (String) this.getProperty(PROPERTY_FONT_NAME); logger.debug("Font name : " + fontName); fontName = fontName != null ? fontName : DEFAULT_FONT_NAME; font.setFontName(fontName);// w w w . j a v a2s . c o m String cellColor = (String) this.getProperty(PROPERTY_CELL_COLOR); logger.debug("Cell color : " + cellColor); short cellColorIndex = cellColor != null ? IndexedColors.valueOf(cellColor).getIndex() : IndexedColors.valueOf(DEFAULT_CELL_COLOR).getIndex(); font.setColor(cellColorIndex); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.qbe.exporter.QbeXLSExporter.java
License:Mozilla Public License
public CellStyle buildHeaderCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER); String headerBGColor = (String) this.getProperty(PROPERTY_HEADER_BACKGROUND_COLOR); logger.debug("Header background color : " + headerBGColor); short backgroundColorIndex = headerBGColor != null ? IndexedColors.valueOf(headerBGColor).getIndex() : IndexedColors.valueOf(DEFAULT_HEADER_BACKGROUND_COLOR).getIndex(); cellStyle.setFillForegroundColor(backgroundColorIndex); cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); cellStyle.setBorderBottom(CellStyle.BORDER_THIN); cellStyle.setBorderLeft(CellStyle.BORDER_THIN); cellStyle.setBorderRight(CellStyle.BORDER_THIN); cellStyle.setBorderTop(CellStyle.BORDER_THIN); String bordeBorderColor = (String) this.getProperty(PROPERTY_HEADER_BORDER_COLOR); logger.debug("Header border color : " + bordeBorderColor); short borderColorIndex = bordeBorderColor != null ? IndexedColors.valueOf(bordeBorderColor).getIndex() : IndexedColors.valueOf(DEFAULT_HEADER_BORDER_COLOR).getIndex(); cellStyle.setLeftBorderColor(borderColorIndex); cellStyle.setRightBorderColor(borderColorIndex); cellStyle.setBottomBorderColor(borderColorIndex); cellStyle.setTopBorderColor(borderColorIndex); Font font = sheet.getWorkbook().createFont(); Short headerFontSize = (Short) this.getProperty(PROPERTY_HEADER_FONT_SIZE); logger.debug("Header font size : " + headerFontSize); short headerFontSizeShort = headerFontSize != null ? headerFontSize.shortValue() : DEFAULT_HEADER_FONT_SIZE; font.setFontHeightInPoints(headerFontSizeShort); String fontName = (String) this.getProperty(PROPERTY_FONT_NAME); logger.debug("Font name : " + fontName); fontName = fontName != null ? fontName : DEFAULT_FONT_NAME; font.setFontName(fontName);//from ww w . j a v a2s. co m String headerColor = (String) this.getProperty(PROPERTY_HEADER_COLOR); logger.debug("Header color : " + headerColor); short headerColorIndex = bordeBorderColor != null ? IndexedColors.valueOf(headerColor).getIndex() : IndexedColors.valueOf(DEFAULT_HEADER_COLOR).getIndex(); font.setColor(headerColorIndex); font.setBoldweight(Font.BOLDWEIGHT_BOLD); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.qbe.exporter.QbeXLSExporter.java
License:Mozilla Public License
public CellStyle buildCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_RIGHT); cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER); String cellBGColor = (String) this.getProperty(PROPERTY_CELL_BACKGROUND_COLOR); logger.debug("Cell background color : " + cellBGColor); short backgroundColorIndex = cellBGColor != null ? IndexedColors.valueOf(cellBGColor).getIndex() : IndexedColors.valueOf(DEFAULT_CELL_BACKGROUND_COLOR).getIndex(); cellStyle.setFillForegroundColor(backgroundColorIndex); cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); cellStyle.setBorderBottom(CellStyle.BORDER_THIN); cellStyle.setBorderLeft(CellStyle.BORDER_THIN); cellStyle.setBorderRight(CellStyle.BORDER_THIN); cellStyle.setBorderTop(CellStyle.BORDER_THIN); String bordeBorderColor = (String) this.getProperty(PROPERTY_CELL_BORDER_COLOR); logger.debug("Cell border color : " + bordeBorderColor); short borderColorIndex = bordeBorderColor != null ? IndexedColors.valueOf(bordeBorderColor).getIndex() : IndexedColors.valueOf(DEFAULT_CELL_BORDER_COLOR).getIndex(); cellStyle.setLeftBorderColor(borderColorIndex); cellStyle.setRightBorderColor(borderColorIndex); cellStyle.setBottomBorderColor(borderColorIndex); cellStyle.setTopBorderColor(borderColorIndex); Font font = sheet.getWorkbook().createFont(); Short cellFontSize = (Short) this.getProperty(PROPERTY_CELL_FONT_SIZE); logger.debug("Cell font size : " + cellFontSize); short cellFontSizeShort = cellFontSize != null ? cellFontSize.shortValue() : DEFAULT_CELL_FONT_SIZE; font.setFontHeightInPoints(cellFontSizeShort); String fontName = (String) this.getProperty(PROPERTY_FONT_NAME); logger.debug("Font name : " + fontName); fontName = fontName != null ? fontName : DEFAULT_FONT_NAME; font.setFontName(fontName);/*from w ww. j a va2s. c o m*/ String cellColor = (String) this.getProperty(PROPERTY_CELL_COLOR); logger.debug("Cell color : " + cellColor); short cellColorIndex = cellColor != null ? IndexedColors.valueOf(cellColor).getIndex() : IndexedColors.valueOf(DEFAULT_CELL_COLOR).getIndex(); font.setColor(cellColorIndex); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetXLSExporter.java
License:Mozilla Public License
public CellStyle buildHeaderTitleCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); Font font = sheet.getWorkbook().createFont(); font.setFontHeightInPoints(HEADER_FONT_SIZE); font.setFontName(FONT_NAME);/*from w w w. jav a 2 s.c om*/ font.setColor(IndexedColors.DARK_BLUE.getIndex()); font.setBoldweight(Font.BOLDWEIGHT_BOLD); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetXLSExporter.java
License:Mozilla Public License
public CellStyle buildMetadataTitleCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); cellStyle.setWrapText(true);/* ww w. ja va 2 s. c om*/ Font font = sheet.getWorkbook().createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints(METADATA_TITLE_FONT_SIZE); font.setFontName(FONT_NAME); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetXLSExporter.java
License:Mozilla Public License
public CellStyle buildMetadataNameCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); cellStyle.setWrapText(true);/*from www. ja va2 s .com*/ Font font = sheet.getWorkbook().createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints(METADATA_NAME_FONT_SIZE); font.setFontName(FONT_NAME); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetXLSExporter.java
License:Mozilla Public License
public CellStyle buildMetadataValueCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); cellStyle.setWrapText(true);/*from w w w. j av a 2s .c o m*/ Font font = sheet.getWorkbook().createFont(); font.setFontHeightInPoints(METADATA_VALUE_FONT_SIZE); font.setFontName(FONT_NAME); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetXLSExporter.java
License:Mozilla Public License
public CellStyle buildFiltersTitleCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyle.setWrapText(false);/* ww w. j ava 2 s . c o m*/ Font font = sheet.getWorkbook().createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints(FILTERS_TITLE_FONT_SIZE); font.setFontName(FONT_NAME); cellStyle.setFont(font); return cellStyle; }
From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetXLSExporter.java
License:Mozilla Public License
public CellStyle buildFiltersValuesCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyle.setWrapText(false);/*w w w.jav a 2 s . c om*/ Font font = sheet.getWorkbook().createFont(); font.setFontHeightInPoints(FILTERS_VALUES_FONT_SIZE); font.setFontName(FONT_NAME); cellStyle.setFont(font); return cellStyle; }
From source file:javaapp.generateAnomolies.java
public static void generateAnomolyReport() throws IOException { XSSFWorkbook workbook = new XSSFWorkbook(); HashMap<String, List<String>> hmd = new HashMap<String, List<String>>(); HashMap<String, List<String>> hmc = new HashMap<String, List<String>>(); HashMap<String, List<String>> uhmd = new HashMap<String, List<String>>(); HashMap<String, List<String>> uhmc = new HashMap<String, List<String>>(); hmd = getAnomolies("transrec", "Debtors", 0); hmc = getAnomolies("ctransrec", "Creditors", 1); uhmd = getAnomoliesUninv("uninv", "Uninv_Debtors", 2); uhmc = getAnomoliesUninv("cuninv", "Uninv_Creditors", 3); List ls;//from w ww . j a v a2s . c o m List ls2, ls3, ls4; Font font = workbook.createFont(); font.setFontHeightInPoints((short) 12); font.setFontName("Cambria"); Font hfont = workbook.createFont(); hfont.setFontHeightInPoints((short) 12); hfont.setFontName("Cambria"); CellStyle style = workbook.createCellStyle(); CellStyle hstyle = workbook.createCellStyle(); style.setFont(font); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); hstyle.setFont(font); hstyle.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex()); hstyle.setFillPattern(CellStyle.SOLID_FOREGROUND); //System.out.println(hm); XSSFSheet sheet = workbook.createSheet("Debtors"); XSSFSheet sheet2 = workbook.createSheet("Creditors"); XSSFSheet sheet3 = workbook.createSheet("Uninv_Debtors"); XSSFSheet sheet4 = workbook.createSheet("Uninv_Creditors"); Iterator iterator = hmd.keySet().iterator(); int rowCount = 0; Row row = sheet.createRow(0); Cell hcell = row.createCell(1); hcell.setCellValue((String) "RPPS"); hcell.setCellStyle(hstyle); hcell = row.createCell(2); hcell.setCellValue((String) "SVC"); hcell.setCellStyle(hstyle); hcell = row.createCell(3); hcell.setCellValue((String) "OPEN"); hcell.setCellStyle(hstyle); hcell = row.createCell(4); hcell.setCellValue((String) "RINVOICE"); hcell.setCellStyle(hstyle); hcell = row.createCell(5); hcell.setCellValue((String) "CORRECTION"); hcell.setCellStyle(hstyle); hcell = row.createCell(6); hcell.setCellValue((String) "ADJUST"); hcell.setCellStyle(hstyle); hcell = row.createCell(7); hcell.setCellValue((String) "O1C"); hcell.setCellStyle(hstyle); hcell = row.createCell(8); hcell.setCellValue((String) "SETTLED"); hcell.setCellStyle(hstyle); hcell = row.createCell(9); hcell.setCellValue((String) "ALLOC"); hcell.setCellStyle(hstyle); hcell = row.createCell(10); hcell.setCellValue((String) "WRITEOFF"); hcell.setCellStyle(hstyle); hcell = row.createCell(11); hcell.setCellValue((String) "CLOSE"); hcell.setCellStyle(hstyle); hcell = row.createCell(12); hcell.setCellValue((String) "RECDIFF"); hcell.setCellStyle(hstyle); while (iterator.hasNext()) { row = sheet.createRow(++rowCount); int columnCount = 0; String field = ""; String key = iterator.next().toString(); field = key; Cell cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); cell.setCellStyle(style); } //System.out.println(hm.get(key)); ls = (List<String>) hmd.get(key); System.out.println(ls); Iterator<String> ite = ls.iterator(); while (ite.hasNext()) { field = ite.next(); //System.out.println( ite.next() ); cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); } cell.setCellStyle(style); } } Iterator iterator2 = hmc.keySet().iterator(); rowCount = 0; while (iterator2.hasNext()) { row = sheet2.createRow(++rowCount); int columnCount = 0; String field = ""; String key = iterator2.next().toString(); field = key; Cell cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); cell.setCellStyle(style); } //System.out.println(hm.get(key)); ls2 = (List<String>) hmc.get(key); System.out.println(ls2); Iterator<String> ite = ls2.iterator(); while (ite.hasNext()) { field = ite.next(); //System.out.println( ite.next() ); cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); cell.setCellStyle(style); } } } // uninv debtors Iterator iterator3 = uhmd.keySet().iterator(); rowCount = 0; while (iterator3.hasNext()) { row = sheet3.createRow(++rowCount); int columnCount = 0; String field = ""; String key = iterator3.next().toString(); field = key; Cell cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); cell.setCellStyle(style); } //System.out.println(hm.get(key)); ls3 = (List<String>) hmc.get(key); System.out.println(ls3); Iterator<String> ite = ls3.iterator(); while (ite.hasNext()) { field = ite.next(); //System.out.println( ite.next() ); cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); cell.setCellStyle(style); } } } // uninv creditors Iterator iterator4 = uhmc.keySet().iterator(); rowCount = 0; while (iterator4.hasNext()) { row = sheet4.createRow(++rowCount); int columnCount = 0; String field = ""; String key = iterator4.next().toString(); field = key; Cell cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); cell.setCellStyle(style); } //System.out.println(hm.get(key)); ls4 = (List<String>) uhmc.get(key); System.out.println(ls4); Iterator<String> ite = ls4.iterator(); while (ite.hasNext()) { field = ite.next(); //System.out.println( ite.next() ); cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); cell.setCellStyle(style); } } } /* Object[][] bookData = { {"Head First Java", "Kathy Serria", 79}, {"Effective Java", "Joshua Bloch", 36}, {"Clean Code", "Robert martin", 42}, {"Thinking in Java", "Bruce Eckel", 35}, }; //int rowCount = 0; for (Object[] aBook : bookData) { Row row = sheet.createRow(++rowCount); int columnCount = 0; for (Object field : aBook) { Cell cell = row.createCell(++columnCount); if (field instanceof String) { cell.setCellValue((String) field); } else if (field instanceof Integer) { cell.setCellValue((Integer) field); } } } */ // workbook.setSheetName(n, WorkbookUtil.createSafeSheetName("Debtors")); try (FileOutputStream outputStream = new FileOutputStream("anomolies/GBRCN_Anomolies_27April.xlsx")) { workbook.write(outputStream); } }