List of usage examples for org.apache.poi.ss.usermodel Cell setCellStyle
void setCellStyle(CellStyle style);
Set the style for the cell.
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.CommentXlsReportHelper.java
License:Apache License
/** * Adds the table header to the sheet/*from w w w .j a v a2 s . c om*/ * * @param p_sheet */ private void addHeader(Workbook p_workbook, Sheet p_sheet) throws Exception { int col = 0; Row headerRow = getRow(p_sheet, 3); Cell cell_A = getCell(headerRow, col++); cell_A.setCellValue(bundle.getString("job_id")); cell_A.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 10 * 256); Cell cell_B = getCell(headerRow, col++); cell_B.setCellValue(bundle.getString("job_name")); cell_B.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 20 * 256); Cell cell_C = getCell(headerRow, col++); cell_C.setCellValue(bundle.getString("comment_type")); cell_C.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 15 * 256); Cell cell_D = getCell(headerRow, col++); cell_D.setCellValue(bundle.getString("language")); cell_D.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 25 * 256); Cell cell_E = getCell(headerRow, col++); cell_E.setCellValue(bundle.getString("segment_number")); cell_E.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 15 * 256); Cell cell_F = getCell(headerRow, col++); cell_F.setCellValue(bundle.getString("by_who")); cell_F.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 15 * 256); Cell cell_G = getCell(headerRow, col++); cell_G.setCellValue(bundle.getString("on_date")); cell_G.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 25 * 256); if (showStatus) { Cell cell_Status = getCell(headerRow, col++); cell_Status.setCellValue(bundle.getString("status")); cell_Status.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 10 * 256); } if (showPriority) { Cell cell_Priority = getCell(headerRow, col++); cell_Priority.setCellValue(bundle.getString("priority")); cell_Priority.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 10 * 256); } if (showCategory) { Cell cell_Category = getCell(headerRow, col++); cell_Category.setCellValue(bundle.getString("category")); cell_Category.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 40 * 256); } if (showSourAndTar) { Cell cell_Source = getCell(headerRow, col++); cell_Source.setCellValue(bundle.getString("source_segment")); cell_Source.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 40 * 256); Cell cell_Target = getCell(headerRow, col++); cell_Target.setCellValue(bundle.getString("target_segment")); cell_Target.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 40 * 256); } Cell cell_CommentHeader = getCell(headerRow, col++); cell_CommentHeader.setCellValue(bundle.getString("comment_header")); cell_CommentHeader.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 20 * 256); Cell cell_CommentBody = getCell(headerRow, col++); cell_CommentBody.setCellValue(bundle.getString("comment_body")); cell_CommentBody.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 25 * 256); Cell cell_Link = getCell(headerRow, col++); cell_Link.setCellValue(bundle.getString("link")); cell_Link.setCellStyle(getHeaderStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 40 * 256); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.CommentXlsReportHelper.java
License:Apache License
/** * add Comment for each row of each sheet * /*from w w w. j a va 2s . com*/ * @exception Exception */ private void addComment(HttpServletRequest p_request, Job j, Workbook p_workbook, Sheet p_sheet, IntHolder row, Comment comment, int flag) throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat(p_request.getParameter("dateFormat")); String jobPrefix = "Job Comment "; String taskPrefix = "Activity Comment "; int c = 0; int r = row.getValue(); Row p_row = getRow(p_sheet, r); // 2.3 Job ID column. Insert GlobalSight job number here. Cell cell_A = getCell(p_row, c++); cell_A.setCellValue(j.getJobId()); cell_A.setCellStyle(getContentStyle(p_workbook)); // 2.4 Job: Insert Job name here. Cell cell_B = getCell(p_row, c++); cell_B.setCellValue(j.getJobName()); cell_B.setCellStyle(getContentStyle(p_workbook)); //Insert comment type Cell cell_C = getCell(p_row, c++); if (JOB_FLAG == flag) { cell_C.setCellValue(jobPrefix); cell_C.setCellStyle(getContentStyle(p_workbook)); } else if (TASK_FLAG == flag) { cell_C.setCellValue(taskPrefix); cell_C.setCellStyle(getContentStyle(p_workbook)); } // 2.5 Lang: Insert each target language identifier for each workflow // in the retrieved Job on a different row. Cell cell_D = getCell(p_row, c++); if ((this.targetPageVar != null) && (this.targetPageVar.getGlobalSightLocale() != null)) { cell_D.setCellValue(this.targetPageVar.getGlobalSightLocale().getDisplayName(uiLocale)); cell_D.setCellStyle(getContentStyle(p_workbook)); } else { cell_D.setCellValue(""); cell_D.setCellStyle(getContentStyle(p_workbook)); } // 2.6 Word count: Insert Segement Number for the job. Cell cell_E = getCell(p_row, c++); cell_E.setCellValue(""); cell_E.setCellStyle(getContentStyle(p_workbook)); // by who Cell cell_F = getCell(p_row, c++); cell_F.setCellValue(UserUtil.getUserNameById(comment.getCreatorId())); cell_F.setCellStyle(getContentStyle(p_workbook)); // 2.7 Comment create date: Insert Comment creation date. Cell cell_G = getCell(p_row, c++); cell_G.setCellValue(dateFormat.format(comment.getCreatedDateAsDate())); cell_G.setCellStyle(getContentStyle(p_workbook)); // 2.8 add Comment Status if (showStatus) { Cell cell_Status = getCell(p_row, c++); cell_Status.setCellValue(""); cell_Status.setCellStyle(getContentStyle(p_workbook)); } // 2.9 add Comment priority if (showPriority) { Cell cell_Priority = getCell(p_row, c++); cell_Priority.setCellValue(""); cell_Priority.setCellStyle(getContentStyle(p_workbook)); } // 2.10 add Comment Category if (showCategory) { Cell cell_Category = getCell(p_row, c++); cell_Category.setCellValue(""); cell_Category.setCellStyle(getContentStyle(p_workbook)); } //add source and target segment if (showSourAndTar) { Cell cell_Source = getCell(p_row, c++); cell_Source.setCellValue(""); cell_Source.setCellStyle(getContentStyle(p_workbook)); Cell cell_Target = getCell(p_row, c++); cell_Target.setCellValue(""); cell_Target.setCellStyle(getContentStyle(p_workbook)); } // 2.11 add Comment comment Cell cell_CommentHeader = getCell(p_row, c++); cell_CommentHeader.setCellValue(""); cell_CommentHeader.setCellStyle(getContentStyle(p_workbook)); Cell cell_CommentBody = getCell(p_row, c++); cell_CommentBody.setCellValue(comment.getComment()); cell_CommentBody.setCellStyle(getContentStyle(p_workbook)); Cell cell_Link = getCell(p_row, c++); if (flag != SEGMENT_FLAG) { cell_Link.setCellValue(""); } else { cell_Link.setCellFormula("HYPERLINK(\"" + pageUrl + "\",\"" + externalPageId + "\")"); } cell_Link.setCellStyle(getContentStyle(p_workbook)); row.inc(); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.CommentXlsReportHelper.java
License:Apache License
/** * add Comment for each row, for segment comment usage, each row contains a * comment history/*from ww w. j a v a 2 s .com*/ * * @exception Exception */ private void addCommentHistory(HttpServletRequest p_request, Job j, Workbook p_workbook, Sheet p_sheet, IntHolder row, Comment comment, IssueHistory issueHistory, int flag) throws Exception { String segmentPrefix = "Segment Comment"; SimpleDateFormat dateFormat = new SimpleDateFormat(p_request.getParameter("dateFormat")); int c = 0; int r = row.getValue(); // 2.3.2 Job ID column. Insert GlobalSight job number here. Row p_row = getRow(p_sheet, r); Cell cell_A = getCell(p_row, c++); cell_A.setCellValue(j.getJobId()); cell_A.setCellStyle(getContentStyle(p_workbook)); // 2.4.2 Job: Insert Job name here. Cell cell_B = getCell(p_row, c++); cell_B.setCellValue(j.getJobName()); cell_B.setCellStyle(getContentStyle(p_workbook)); Cell cell_C = getCell(p_row, c++); cell_C.setCellValue(segmentPrefix); cell_C.setCellStyle(getContentStyle(p_workbook)); // 2.5.2 Lang: Insert each target language identifier for each workflow // in the retrieved Job on a different row. Cell cell_D = getCell(p_row, c++); if ((this.targetPageVar != null) && (this.targetPageVar.getGlobalSightLocale() != null)) { cell_D.setCellValue(this.targetPageVar.getGlobalSightLocale().getDisplayName(uiLocale)); cell_D.setCellStyle(getContentStyle(p_workbook)); } else { cell_D.setCellValue(""); cell_D.setCellStyle(getContentStyle(p_workbook)); } // 2.6.2 Insert Segement Number for the job. Cell cell_E = getCell(p_row, c++); Integer segmentNum = Integer .valueOf(CommentComparator.getSegmentIdFromLogicalKey(((Issue) comment).getLogicalKey())); cell_E.setCellValue(segmentNum); cell_E.setCellStyle(getContentStyle(p_workbook)); // by who Cell cell_F = getCell(p_row, c++); cell_F.setCellValue(UserUtil.getUserNameById(issueHistory.reportedBy())); cell_F.setCellStyle(getContentStyle(p_workbook)); // 2.7.2 Comment create date: Insert Comment creation date.\ Cell cell_G = getCell(p_row, c++); cell_G.setCellValue(dateFormat.format(issueHistory.dateReportedAsDate())); cell_G.setCellStyle(getContentStyle(p_workbook)); // 2.8.2 add Comment Status if (showStatus) { Cell cell_Status = getCell(p_row, c++); cell_Status.setCellValue(((Issue) comment).getStatus()); cell_Status.setCellStyle(getContentStyle(p_workbook)); } // 2.9.2 add Comment priority if (showPriority) { Cell cell_Priority = getCell(p_row, c++); cell_Priority.setCellValue(((Issue) comment).getPriority()); cell_Priority.setCellStyle(getContentStyle(p_workbook)); } // 2.10.2 add Comment Category if (showCategory) { Cell cell_Category = getCell(p_row, c++); cell_Category.setCellValue(((Issue) comment).getCategory()); cell_Category.setCellStyle(getContentStyle(p_workbook)); } if (showSourAndTar) { long targetLocalId = this.targetPageVar.getGlobalSightLocale().getId(); long sourceLocalId = j.getSourceLocale().getId(); Tuv sourceTuv = SegmentTuvUtil.getTuvByTuIdLocaleId(segmentNum, sourceLocalId, j.getId()); Tuv targetTuv = SegmentTuvUtil.getTuvByTuIdLocaleId(segmentNum, targetLocalId, j.getId()); PseudoData pData = new PseudoData(); pData.setMode(PseudoConstants.PSEUDO_COMPACT); Cell cell_SourceSegment = getCell(p_row, c++); cell_SourceSegment.setCellValue(getSegment(pData, sourceTuv, j.getId())); cell_SourceSegment.setCellStyle(getContentStyle(p_workbook)); Cell cell_TargetSegment = getCell(p_row, c++); cell_TargetSegment.setCellValue(getSegment(pData, targetTuv, j.getId())); cell_TargetSegment.setCellStyle(getContentStyle(p_workbook)); } // 2.11.2 add comment header Cell cell_CommentHeader = getCell(p_row, c++); cell_CommentHeader.setCellValue(comment.getComment()); cell_CommentHeader.setCellStyle(getContentStyle(p_workbook)); // 2.12.2 add comment body Cell cell_CommentBody = getCell(p_row, c++); cell_CommentBody.setCellValue(issueHistory.getComment()); cell_CommentBody.setCellStyle(getContentStyle(p_workbook)); // 2.13.2 add link Cell cell_Link = getCell(p_row, c++); cell_Link.setCellFormula("HYPERLINK(\"" + pageUrl + "\",\"" + externalPageId + "\")"); cell_Link.setCellStyle(getContentStyle(p_workbook)); row.inc(); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.customize.ExcelReportWriter.java
License:Apache License
public void addTitleCell(int column, int row, String label) throws IOException { Cell cell = getCell(getRow(row), column); cell.setCellValue(label);// w ww . j a va2 s. c o m cell.setCellStyle(titleStyle); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.customize.ExcelReportWriter.java
License:Apache License
public void addHeaderCell(int column, int row, String label) throws IOException { Cell cell = getCell(getRow(row), column); cell.setCellValue(label);/* w w w . j av a2 s . c o m*/ cell.setCellStyle(headerStyle); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.customize.ExcelReportWriter.java
License:Apache License
public void addContentCell(int column, int row, Object contentObj) throws IOException { Cell cell = getCell(getRow(row), column); if (contentObj instanceof BigDecimal) { cell.setCellValue(((BigDecimal) contentObj).doubleValue()); cell.setCellStyle(moneyStyle); } else if (contentObj instanceof Long) { cell.setCellValue(((Long) contentObj).longValue()); cell.setCellStyle(intStyle);//from w ww . ja va2s. c o m } else if (contentObj instanceof Integer) { cell.setCellValue(((Integer) contentObj).intValue()); cell.setCellStyle(intStyle); } else { cell.setCellValue(contentObj.toString()); cell.setCellStyle(stringStyle); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.customize.ExcelReportWriter.java
License:Apache License
public void addTotal(final int totalRow, List total) throws IOException { Cell totalCell = getCell(getRow(totalRow), 0); totalCell.setCellValue(bundle.getString("lb_total")); totalCell.setCellStyle(totalStyle); for (int i = 1; i < total.size(); i++) { Cell cell = getCell(getRow(totalRow), i); if (total.get(i) instanceof BigDecimal) { cell.setCellValue(((BigDecimal) total.get(i)).doubleValue()); cell.setCellStyle(totalMoneyStyle); } else if (total.get(i) instanceof Long) { cell.setCellValue(((Long) total.get(i)).longValue()); cell.setCellStyle(totalStyle); } else {// ww w. j a v a2 s.com cell.setCellValue(""); cell.setCellStyle(totalStyle); } } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.customize.ExcelReportWriter.java
License:Apache License
public void setRegionStyle(Sheet sheet, CellRangeAddress cellRangeAddress, CellStyle cs) { for (int i = cellRangeAddress.getFirstRow(); i <= cellRangeAddress.getLastRow(); i++) { Row row = getRow(i);//from ww w. j a v a2 s . com for (int j = cellRangeAddress.getFirstColumn(); j <= cellRangeAddress.getLastColumn(); j++) { Cell cell = getCell(row, j); cell.setCellStyle(cs); } } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CharacterCountReportGenerator.java
License:Apache License
/** * Add title to the sheet//from ww w . j a v a 2 s . c om * * @param p_workBook * @param p_sheet * the sheet * @throws Exception */ private void addTitle(Workbook p_workBook, Sheet p_sheet) throws Exception { ResourceBundle bundle = m_bundle; // Title font is black bold on white Font titleFont = p_workBook.createFont(); titleFont.setUnderline(Font.U_NONE); titleFont.setFontName("Times"); titleFont.setFontHeightInPoints((short) 14); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); CellStyle cs = p_workBook.createCellStyle(); cs.setFont(titleFont); Row titleRow = getRow(p_sheet, 0); Cell titleCell = getCell(titleRow, 0); titleCell.setCellValue(bundle.getString("character_count_report")); titleCell.setCellStyle(cs); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CharacterCountReportGenerator.java
License:Apache License
/** * Add job header to the sheet//from w w w. j ava2s. c o m * * @param p_workBook * @param p_sheet * the sheet * @throws Exception */ private void addLanguageHeader(Workbook p_workBook, Sheet p_sheet) throws Exception { ResourceBundle bundle = m_bundle; int col = 0; int row = LANGUAGE_HEADER_ROW; Row langRow = getRow(p_sheet, row); Cell srcLangCell = getCell(langRow, col); srcLangCell.setCellValue(bundle.getString("lb_source_language")); srcLangCell.setCellStyle(getHeaderStyle(p_workBook)); col++; Cell trgLangCell = getCell(langRow, col); trgLangCell.setCellValue(bundle.getString("lb_target_language")); trgLangCell.setCellStyle(getHeaderStyle(p_workBook)); col++; Cell jobIdCell = getCell(langRow, col); jobIdCell.setCellValue(bundle.getString("jobinfo.jobid")); jobIdCell.setCellStyle(getHeaderStyle(p_workBook)); col++; Cell TotalSegmentsCell = getCell(langRow, col); TotalSegmentsCell.setCellValue(bundle.getString("lb_segmentCount_in_job")); TotalSegmentsCell.setCellStyle(getHeaderStyle(p_workBook)); }