List of usage examples for org.apache.poi.ss.usermodel Workbook createCellStyle
CellStyle createCellStyle();
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ImplementedCommentsCheckReportGenerator.java
License:Apache License
/** * // w w w . ja va2 s. c o m * @return format of the unlocked cell * @throws Exception */ private CellStyle getUnlockedStyle(Workbook p_workbook) throws Exception { if (unlockedStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font); style.setLocked(false); style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); unlockedStyle = style; } return unlockedStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ImplementedCommentsCheckReportGenerator.java
License:Apache License
private CellStyle getRedStyle(Workbook p_workbook) throws Exception { CellStyle style = p_workbook.createCellStyle(); Font font = p_workbook.createFont(); if (hightLightStyle == null) { font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.BLACK.getIndex()); font.setUnderline(Font.U_NONE); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); style.setWrapText(true);// www.j a v a2 s .co m style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.ROSE.getIndex()); hightLightStyle = style; } return hightLightStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private void addTitle(Workbook p_workbook, Sheet p_sheet) throws Exception { String EMEA = CompanyWrapper.getCurrentCompanyName(); Font titleFont = p_workbook.createFont(); titleFont.setUnderline(Font.U_NONE); titleFont.setFontName("Arial"); titleFont.setFontHeightInPoints((short) 14); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); CellStyle titleStyle = p_workbook.createCellStyle(); titleStyle.setWrapText(false);//w w w .j av a 2 s. c om titleStyle.setFont(titleFont); Row firRow = getRow(p_sheet, 0); Cell titleCell = getCell(firRow, 0); titleCell.setCellValue(EMEA + " " + m_bundle.getString("online_jobs_for_ip_translator")); titleCell.setCellStyle(titleStyle); p_sheet.setColumnWidth(0, 20 * 256); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private void addTotalsPerLang(Workbook p_workbook, Sheet p_sheet, final int p_sheetCategory, IntHolder p_row) throws Exception { Font subTotalFont = p_workbook.createFont(); subTotalFont.setBoldweight(Font.BOLDWEIGHT_BOLD); subTotalFont.setColor(IndexedColors.BLACK.getIndex()); subTotalFont.setUnderline(Font.U_NONE); subTotalFont.setFontName("Arial"); subTotalFont.setFontHeightInPoints((short) 10); CellStyle subTotalStyle = p_workbook.createCellStyle(); subTotalStyle.setFont(subTotalFont); String title = m_bundle.getString("lb_total_cost_per_lang"); int row = p_row.getValue() + 4; // skip a row ArrayList<String> locales = new ArrayList<String>(totalCost.keySet()); SortUtil.sort(locales);/*w ww .java 2 s. c o m*/ int col = m_data.getSumStartCol(); Row theRow = getRow(p_sheet, row); Cell cell_Title = getCell(theRow, col - 3); cell_Title.setCellValue(title); cell_Title.setCellStyle(subTotalStyle); File imgFile = File.createTempFile("GSJobChart", ".png"); JfreeCharUtil.drawPieChart2D("", totalCostDate, imgFile); Drawing patriarch = p_sheet.createDrawingPatriarch(); XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 15, row - 1, 22, row + 24); ByteArrayOutputStream img_bytes = new ByteArrayOutputStream(); InputStream is = imgFile.toURI().toURL().openStream(); int b; while ((b = is.read()) != -1) { img_bytes.write(b); } is.close(); int i = p_workbook.addPicture(img_bytes.toByteArray(), SXSSFWorkbook.PICTURE_TYPE_PNG); patriarch.createPicture(anchor, i); for (String locale : locales) { List<Integer> indexs = totalCost.get(locale); StringBuffer values = new StringBuffer(); for (Integer index : indexs) { if (values.length() == 0) { values.append("SUM("); } else { values.append("+"); } values.append(totalCol).append(index); } values.append(")"); Row perRow = getRow(p_sheet, row); Cell cell_Locale = getCell(perRow, col - 1); cell_Locale.setCellValue(locale); cell_Locale.setCellStyle(getContentStyle(p_workbook)); Cell cell_Total = getCell(perRow, col); cell_Total.setCellFormula(values.toString()); cell_Total.setCellStyle(getMoneyStyle(p_workbook)); row++; } // Reset total column number for every sheet. totalCol = null; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private CellStyle getHeaderStyle(Workbook p_workbook) { if (headerStyle == null) { Font headerFont = p_workbook.createFont(); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); headerFont.setColor(IndexedColors.BLACK.getIndex()); headerFont.setUnderline(Font.U_NONE); headerFont.setFontName("Arial"); headerFont.setFontHeightInPoints((short) 9); CellStyle cs = p_workbook.createCellStyle(); cs.setFont(headerFont);/*from www. j ava 2s. c om*/ cs.setWrapText(true); cs.setFillPattern(CellStyle.SOLID_FOREGROUND); cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); cs.setBorderTop(CellStyle.BORDER_THIN); cs.setBorderRight(CellStyle.BORDER_THIN); cs.setBorderBottom(CellStyle.BORDER_THIN); cs.setBorderLeft(CellStyle.BORDER_THIN); headerStyle = cs; } return headerStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private CellStyle getContentStyle(Workbook p_workbook) throws Exception { if (contentStyle == null) { CellStyle style = p_workbook.createCellStyle(); Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); style.setFont(font);// w w w . j a va 2 s . co m contentStyle = style; } return contentStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private CellStyle getDateStyle(Workbook p_workbook) throws Exception { if (dateStyle == null) { DataFormat dataFormat = p_workbook.createDataFormat(); Font dateFont = p_workbook.createFont(); dateFont.setFontName("Arial"); dateFont.setFontHeightInPoints((short) 10); CellStyle cs = p_workbook.createCellStyle(); cs.setWrapText(false);//from w ww. jav a 2 s . co m cs.setFont(dateFont); cs.setDataFormat(dataFormat.getFormat("M/d/yy")); dateStyle = cs; } return dateStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private CellStyle getMoneyStyle(Workbook p_workbook) throws Exception { if (moneyStyle == null) { String euroJavaNumberFormat = getCurrencyNumberFormat(); DataFormat euroNumberFormat = p_workbook.createDataFormat(); CellStyle cs = p_workbook.createCellStyle(); cs.setDataFormat(euroNumberFormat.getFormat(euroJavaNumberFormat)); cs.setWrapText(false);// w ww . j av a2 s . c o m moneyStyle = cs; } return moneyStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private CellStyle getRedCellStyle(Workbook p_workbook) throws Exception { if (redCellStyle == null) { Font redFont = p_workbook.createFont(); redFont.setFontName("Arial"); redFont.setUnderline(Font.U_NONE); redFont.setFontHeightInPoints((short) 10); CellStyle cs = p_workbook.createCellStyle(); cs.setFont(redFont);// w w w .j av a 2 s. c o m cs.setWrapText(true); cs.setFillPattern(CellStyle.SOLID_FOREGROUND); cs.setFillForegroundColor(IndexedColors.RED.getIndex()); redCellStyle = cs; } return redCellStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private CellStyle getFailedDateStyle(Workbook p_workbook) throws Exception { if (failedDateStyle == null) { DataFormat dataFormat = p_workbook.createDataFormat(); Font dateFont = p_workbook.createFont(); dateFont.setFontName("Arial"); dateFont.setFontHeightInPoints((short) 10); CellStyle cs = p_workbook.createCellStyle(); cs.setWrapText(false);/* www. j ava 2 s . co m*/ cs.setFont(dateFont); cs.setDataFormat(dataFormat.getFormat("M/d/yy")); cs.setFillPattern(CellStyle.SOLID_FOREGROUND); cs.setFillForegroundColor(IndexedColors.RED.getIndex()); failedDateStyle = cs; } return failedDateStyle; }