Example usage for org.apache.poi.ss.usermodel Cell setCellValue

List of usage examples for org.apache.poi.ss.usermodel Cell setCellValue

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell setCellValue.

Prototype

void setCellValue(boolean value);

Source Link

Document

Set a boolean value for the cell

Usage

From source file:com.globalsight.everest.qachecks.QAChecker.java

License:Apache License

private void addTitle(Workbook p_workbook, Sheet p_sheet) {
    Row titleRow = getRow(p_sheet, 0);/*w w w  . j  a  va 2s  .  c  o m*/
    Cell titleCell = getCell(titleRow, 0);
    titleCell.setCellValue(m_bundle.getString("lb_report_qa_report_title"));
    titleCell.setCellStyle(getTitleStyle(p_workbook));
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.CommentXlsReportHelper.java

License:Apache License

private void addTitle(Workbook p_workbook, Sheet p_sheet, String sheetTitle) throws Exception {
    // 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 titileCs = p_workbook.createCellStyle();
    titileCs.setWrapText(false);/*from w  ww  . ja  v  a  2s  .  com*/
    titileCs.setFont(titleFont);

    Row titleRow = getRow(p_sheet, 0);
    Cell titleCell = getCell(titleRow, 0);
    titleCell.setCellValue(sheetTitle);
    titleCell.setCellStyle(titileCs);
    p_sheet.setColumnWidth(0, 22 * 256);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.CommentXlsReportHelper.java

License:Apache License

/**
 * Adds the table header to the sheet/*from w ww.  j  a va2  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  ww. j av  a 2 s . 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// w ww .  j a  v  a  2 s. c o m
 * 
 * @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);
    cell.setCellStyle(titleStyle);// w  w  w . ja  v a  2  s . co m
}

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);
    cell.setCellStyle(headerStyle);/*from   w w  w .j a  v  a2  s. c  o  m*/
}

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);//from   ww  w  .  ja  va  2  s  . com
    } else if (contentObj instanceof Long) {
        cell.setCellValue(((Long) contentObj).longValue());
        cell.setCellStyle(intStyle);
    } 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);//from  w  w  w .ja  v a  2  s  .  c om

    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 {
            cell.setCellValue("");
            cell.setCellStyle(totalStyle);
        }
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CharacterCountReportGenerator.java

License:Apache License

/**
 * Generates Excel reports/*from   w  w w. j  av a 2 s .c  o  m*/
 * 
 * @param p_jobIDS
 *            Job ID List
 * @param p_targetLocales
 *            Target Locales List
 * @param p_companyName
 *            Company Name
 * @throws Exception
 */
public File[] generateReports(List<Long> p_jobIDS, List<GlobalSightLocale> p_targetLocales) throws Exception {
    if (p_jobIDS == null || p_jobIDS.size() == 0) {
        p_jobIDS = m_jobIDS;
        p_targetLocales = m_targetLocales;
    } else if (m_jobIDS == null || m_jobIDS.size() == 0) {
        m_jobIDS = p_jobIDS;
    }
    List<File> workBooks = new ArrayList<File>();
    int finishedJobNum = 0;
    for (long jobID : p_jobIDS) {
        // Cancel generate reports.
        if (isCancelled())
            return null;

        Job job = ServerProxy.getJobHandler().getJobById(jobID);
        if (job == null)
            continue;
        setAllCellStyleNull();

        File file = ReportHelper.getXLSReportFile(getReportType(), job);
        Workbook workBook = new SXSSFWorkbook();
        createReport(workBook, job, p_targetLocales);

        FileOutputStream out = new FileOutputStream(file);
        workBook.write(out);
        out.close();
        ((SXSSFWorkbook) workBook).dispose();

        // Write total Segment Count
        FileInputStream fis = new FileInputStream(file);
        Workbook workbook = ExcelUtil.getWorkbook(file.getAbsolutePath(), fis);
        List<GlobalSightLocale> jobTL = ReportHelper.getTargetLocals(job);
        for (GlobalSightLocale trgLocale : p_targetLocales) {
            if (!jobTL.contains(trgLocale))
                continue;

            Sheet sheet = ExcelUtil.getSheet(workbook, trgLocale.toString());
            Row row = getRow(sheet, 4);
            Cell cell = getCell(row, 3);
            cell.setCellValue(totalSegmentCount.get(trgLocale.getDisplayName(m_uiLocale)).toString());
        }
        out = new FileOutputStream(file);
        workbook.write(out);
        out.close();
        workBooks.add(file);

        // Sets Reports Percent.
        setPercent(++finishedJobNum);
    }

    return ReportHelper.moveReports(workBooks, m_userId);
}