Example usage for org.apache.poi.ss.usermodel Sheet setColumnWidth

List of usage examples for org.apache.poi.ss.usermodel Sheet setColumnWidth

Introduction

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

Prototype

void setColumnWidth(int columnIndex, int width);

Source Link

Document

Set the width (in units of 1/256th of a character width)

The maximum column width for an individual cell is 255 characters.

Usage

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

License:Apache License

private void addSegmentHeaderICC(Workbook p_workbook, Sheet p_sheet) throws Exception {
    ResourceBundle bundle = PageHandler.getBundle(request.getSession());
    int col = 0;/*  w  ww.  j a  va 2  s  .co  m*/
    int row = SEGMENT_HEADER_ROW;
    Row segHeaderRow = getRow(p_sheet, row);
    Cell cell_A = getCell(segHeaderRow, col++);
    cell_A.setCellValue(bundle.getString("lb_job_id_report"));
    cell_A.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_B = getCell(segHeaderRow, col++);
    cell_B.setCellValue(bundle.getString("lb_segment_id"));
    cell_B.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_C = getCell(segHeaderRow, col++);
    cell_C.setCellValue(bundle.getString("lb_page_name"));
    cell_C.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_D = getCell(segHeaderRow, col++);
    cell_D.setCellValue(bundle.getString("lb_source_segment"));
    cell_D.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 40 * 256);

    Cell cell_E = getCell(segHeaderRow, col++);
    cell_E.setCellValue(bundle.getString("lb_target_segment"));
    cell_E.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_F = getCell(segHeaderRow, col++);
    cell_F.setCellValue(bundle.getString("lb_sid"));
    cell_F.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 40 * 256);

    Cell cell_G = getCell(segHeaderRow, col++);
    cell_G.setCellValue(bundle.getString("lb_comment_free"));
    cell_G.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 40 * 256);

    Cell cell_H = getCell(segHeaderRow, col++);
    cell_H.setCellValue(bundle.getString("lb_category_failure"));
    cell_H.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_I = getCell(segHeaderRow, col++);
    cell_I.setCellValue(bundle.getString("lb_tm_match_original"));
    cell_I.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_J = getCell(segHeaderRow, col++);
    cell_J.setCellValue(bundle.getString("lb_glossary_source"));
    cell_J.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_K = getCell(segHeaderRow, col++);
    cell_K.setCellValue(bundle.getString("lb_glossary_target"));
    cell_K.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);
}

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

License:Apache License

/**
 * Add job header to the sheet/*from   www.ja  va 2 s . c o  m*/
 * 
 * @param p_sheet
 *            the sheet
 * @throws Exception
 */
private void addLanguageHeader(Workbook p_workbok, Sheet p_sheet) throws Exception {
    ResourceBundle bundle = PageHandler.getBundle(request.getSession());

    int col = 0;
    int row = LANGUAGE_HEADER_ROW;
    Row langHeaderRow = getRow(p_sheet, row);
    Cell cell_A = getCell(langHeaderRow, col++);
    cell_A.setCellValue(bundle.getString("lb_source_language"));
    cell_A.setCellStyle(getHeaderStyle(p_workbok));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_B = getCell(langHeaderRow, col++);
    cell_B.setCellValue(bundle.getString("lb_target_language"));
    cell_B.setCellStyle(getHeaderStyle(p_workbok));
    p_sheet.setColumnWidth(col - 1, 30 * 256);
}

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

License:Apache License

/**
 * Add title to the sheet/*  w w  w.j  a  v a  2s .  co m*/
 * 
 * @param p_sheet
 *            the sheet
 * @throws Exception
 */
private void addTitle(Workbook p_workbook, Sheet p_sheet) throws Exception {
    ResourceBundle bundle = PageHandler.getBundle(request.getSession());
    // 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);
    titleFont.setColor(IndexedColors.BLACK.getIndex());

    CellStyle titleStyle = p_workbook.createCellStyle();
    titleStyle.setFont(titleFont);
    titleStyle.setWrapText(false);

    Row titleRow = getRow(p_sheet, 0);
    Cell titleCell = getCell(titleRow, 0);
    titleCell.setCellValue(bundle.getString("implemented_comments_check_report"));
    titleCell.setCellStyle(titleStyle);
    p_sheet.setColumnWidth(0, 40 * 256);
}

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

License:Apache License

/**
 * Write the Job information into the header
 * /*  www.ja  v a  2s .  co  m*/
 * @param p_sheet
 *            the sheet
 * @param p_jobId
 *            the job id
 * @param p_targetLang
 *            the displayed target language
 * @param p_dateFormat
 *            the date format
 * @throws Exception
 */
private void writeLanguageInfo(Workbook p_workbook, Sheet p_sheet, long p_jobId, String p_targetLang,
        String p_dateFormat) throws Exception {
    Job job = ServerProxy.getJobHandler().getJobById(p_jobId);
    int col = 0;
    int row = LANGUAGE_INFO_ROW;

    // Source Language
    Row langInfoRow = getRow(p_sheet, row);
    Cell cell_A = getCell(langInfoRow, col++);
    cell_A.setCellValue(job.getSourceLocale().getDisplayName(uiLocale));
    cell_A.setCellStyle(getContentStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    // Target Language
    Cell cell_B = getCell(langInfoRow, col++);
    cell_B.setCellValue(p_targetLang);
    cell_B.setCellStyle(getContentStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

}

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

License:Apache License

/**
 * For Implemented Comments Check Report, Write segment information into
 * each row of the sheet./*w  ww  .j a v a2  s  . c o m*/
 * 
 * @see writeSegmentInfoRCR(WritableSheet, long, long, String, int)
 */
private int writeSegmentInfoICC(Workbook p_workbook, Sheet p_sheet, long p_jobId, String p_targetLang,
        String p_srcPageId, int p_row) throws Exception {
    Job job = ServerProxy.getJobHandler().getJobById(p_jobId);
    long companyId = job.getCompanyId();
    Vector<TargetPage> targetPages = new Vector<TargetPage>();

    TranslationMemoryProfile tmp = null;
    List<String> excludItems = null;
    GlobalSightLocale targetLocale = null;
    for (Workflow workflow : job.getWorkflows()) {
        if (Workflow.PENDING.equals(workflow.getState()) || Workflow.CANCELLED.equals(workflow.getState())
        // || Workflow.EXPORT_FAILED.equals(workflow.getState())
                || Workflow.IMPORT_FAILED.equals(workflow.getState())) {
            continue;
        }
        if (p_targetLang.equals(String.valueOf(workflow.getTargetLocale().getId()))) {
            targetLocale = workflow.getTargetLocale();
            targetPages = workflow.getTargetPages();
            tmp = workflow.getJob().getL10nProfile().getTranslationMemoryProfile();
            if (tmp != null) {
                excludItems = new ArrayList<String>(tmp.getJobExcludeTuTypes());
            }
        }
    }

    if (targetPages.isEmpty()) {
        // If no corresponding target page exists
        // and the row is the initial row, then set the cell blank
        if (SEGMENT_START_ROW == p_row) {
            writeBlank(p_workbook, p_sheet, SEGMENT_START_ROW, 10);
        }
    } else {
        LeverageMatchLingManager leverageMatchLingManager = LingServerProxy.getLeverageMatchLingManager();
        TermLeverageManager termLeverageManager = ServerProxy.getTermLeverageManager();

        Locale sourcePageLocale = job.getSourceLocale().getLocale();
        Locale targetPageLocale = targetLocale.getLocale();
        Map<Long, Set<TermLeverageMatch>> termLeverageMatchResultMap = null;
        TermLeverageOptions termLeverageOptions = getTermLeverageOptions(sourcePageLocale, targetPageLocale,
                job.getL10nProfile().getProject().getTermbaseName(), String.valueOf(job.getCompanyId()));
        if (termLeverageOptions != null) {
            termLeverageMatchResultMap = termLeverageManager.getTermMatchesForPages(job.getSourcePages(),
                    targetLocale);
        }

        String category = null;
        PseudoData pData = new PseudoData();
        pData.setMode(PseudoConstants.PSEUDO_COMPACT);
        String sourceSegmentString = null;
        String targetSegmentString = null;
        String sid = null;
        for (int i = 0; i < targetPages.size(); i++) {
            TargetPage targetPage = (TargetPage) targetPages.get(i);
            SourcePage sourcePage = targetPage.getSourcePage();

            if (!"".equals(p_srcPageId) && !p_srcPageId.equals(String.valueOf(sourcePage.getId()))) {
                // ignore the source pages not equal to the one
                // if the request comes from pop up editor
                continue;
            }
            List sourceTuvs = SegmentTuvUtil.getSourceTuvs(sourcePage);
            List targetTuvs = SegmentTuvUtil.getTargetTuvs(targetPage);
            Map<Long, LeverageSegment> exactMatches = leverageMatchLingManager
                    .getExactMatches(sourcePage.getIdAsLong(), new Long(targetPage.getLocaleId()));
            Map<Long, Set<LeverageMatch>> leverageMatcheMap = leverageMatchLingManager
                    .getFuzzyMatches(sourcePage.getIdAsLong(), new Long(targetPage.getLocaleId()));

            sourcePageLocale = sourcePage.getGlobalSightLocale().getLocale();
            targetPageLocale = targetPage.getGlobalSightLocale().getLocale();

            boolean m_rtlSourceLocale = EditUtil.isRTLLocale(sourcePageLocale.toString());
            boolean m_rtlTargetLocale = EditUtil.isRTLLocale(targetPageLocale.toString());

            // Find segment all comments belong to this target page
            Map<Long, IssueImpl> issuesMap = CommentHelper.getIssuesMap(targetPage.getId());

            for (int j = 0; j < targetTuvs.size(); j++) {
                int col = 0;
                Tuv targetTuv = (Tuv) targetTuvs.get(j);
                Tuv sourceTuv = (Tuv) sourceTuvs.get(j);
                category = sourceTuv.getTu(companyId).getTuType();
                if (excludItems != null && excludItems.contains(category)) {
                    continue;
                }

                // Comment
                List issueHistories = null;
                String lastComment = "";
                String failure = "";
                Date issueCreatedDate = null;
                Issue issue = issuesMap.get(targetTuv.getId());
                if (issue != null) {
                    issueHistories = issue.getHistory();
                    failure = issue.getCategory();
                }
                if (issueHistories != null && issueHistories.size() > 0) {
                    IssueHistory issueHistory = (IssueHistory) issueHistories.get(0);
                    lastComment = issueHistory.getComment();
                    issueCreatedDate = issueHistory.dateReportedAsDate();
                }

                sourceSegmentString = sourceTuv.getGxmlElement().getTextValue();
                sid = sourceTuv.getSid();
                targetSegmentString = targetTuv.getGxmlElement().getTextValue();
                Date targetSegmentModifiedDate = targetTuv.getLastModified();

                StringBuilder matches = getMatches(exactMatches, leverageMatcheMap, targetTuv, sourceTuv);

                // Get Terminology/Glossary Source and Target.
                String sourceTerms = "";
                String targetTerms = "";
                if (termLeverageMatchResultMap != null) {
                    Set<TermLeverageMatch> termLeverageMatchSet = termLeverageMatchResultMap
                            .get(sourceTuv.getId());
                    if (termLeverageMatchSet != null && termLeverageMatchSet.size() > 0) {
                        TermLeverageMatch tlm = termLeverageMatchSet.iterator().next();
                        sourceTerms = tlm.getMatchedSourceTerm();
                        targetTerms = tlm.getMatchedTargetTerm();
                    }
                }

                // For Implemented Comments Check Report (LSO Extension)
                if (lastComment.length() == 0) {
                    continue;
                }

                CellStyle style = getContentStyle(p_workbook);
                // Set color format for target segment changed
                if (targetSegmentModifiedDate.before(issueCreatedDate)) {
                    style = getRedStyle(p_workbook);
                }

                // Job id
                Row row = getRow(p_sheet, p_row);
                Cell cell_A = getCell(row, col++);
                cell_A.setCellValue(p_jobId);
                cell_A.setCellStyle(style);
                p_sheet.setColumnWidth(col - 1, 20 * 256);
                // Segment id
                Cell cell_B = getCell(row, col++);
                cell_B.setCellValue(sourceTuv.getTu(companyId).getId());
                cell_B.setCellStyle(style);
                p_sheet.setColumnWidth(col - 1, 20 * 256);

                // Fix for GBS-1484
                String externalPageId = sourcePage.getExternalPageId();
                String[] pathNames = externalPageId.split("\\\\");
                String Name = pathNames[pathNames.length - 1];
                boolean temp = pathNames[0].contains(")");
                if (temp) {
                    String[] firstNames = pathNames[0].split("\\)");
                    String detailName = firstNames[0];
                    Name = Name + detailName + ")";
                }

                // TargetPage id
                Cell cell_C = getCell(row, col++);
                cell_C.setCellValue(Name);
                cell_C.setCellStyle(style);
                p_sheet.setColumnWidth(col - 1, 20 * 256);

                // Source segment
                CellStyle sourceStyle = m_rtlSourceLocale ? getRtlContentStyle(p_workbook) : style;
                String srcContent = m_rtlSourceLocale ? EditUtil.toRtlString(sourceSegmentString)
                        : sourceSegmentString;

                Cell cell_D = getCell(row, col++);
                cell_D.setCellValue(srcContent);
                cell_D.setCellStyle(sourceStyle);
                p_sheet.setColumnWidth(col - 1, 40 * 256);

                // Target segment
                CellStyle targetStyle = m_rtlTargetLocale ? getRtlContentStyle(p_workbook) : style;
                String content = m_rtlTargetLocale ? EditUtil.toRtlString(targetSegmentString)
                        : targetSegmentString;

                Cell cell_E = getCell(row, col++);
                cell_E.setCellValue(content);
                cell_E.setCellStyle(targetStyle);
                p_sheet.setColumnWidth(col - 1, 40 * 256);

                Cell cell_F = getCell(row, col++);
                cell_F.setCellValue(sid);
                cell_F.setCellStyle(style);
                p_sheet.setColumnWidth(col - 1, 40 * 256);

                CellStyle commentStyle = m_rtlTargetLocale ? getUnlockedRightStyle(p_workbook)
                        : getUnlockedStyle(p_workbook);
                // Set color format for target segment changed
                if (targetSegmentModifiedDate.before(issueCreatedDate)) {
                    commentStyle = m_rtlTargetLocale ? getRedRightStyle(p_workbook) : getRedStyle(p_workbook);
                }

                if (m_rtlTargetLocale) {
                    lastComment = EditUtil.toRtlString(lastComment);
                }

                Cell cell_G = getCell(row, col++);
                cell_G.setCellValue(lastComment);
                cell_G.setCellStyle(commentStyle);
                p_sheet.setColumnWidth(col - 1, 40 * 256);

                // Category failure
                CellStyle cfStyle = getUnlockedStyle(p_workbook);

                // Set color format for target segment changed
                if (targetSegmentModifiedDate.before(issueCreatedDate)) {
                    cfStyle = getRedStyle(p_workbook);
                }

                Cell cell_H = getCell(row, col++);
                cell_H.setCellValue(failure);
                cell_H.setCellStyle(cfStyle);
                p_sheet.setColumnWidth(col - 1, 30 * 256);

                // TM match
                Cell cell_I = getCell(row, col++);
                cell_I.setCellValue(matches.toString());
                cell_I.setCellStyle(style);
                p_sheet.setColumnWidth(col - 1, 30 * 256);

                // Glossary source
                Cell cell_J = getCell(row, col++);
                cell_J.setCellValue(sourceTerms);
                cell_J.setCellStyle(style);
                p_sheet.setColumnWidth(col - 1, 30 * 256);

                // Glossary target
                Cell cell_K = getCell(row, col++);
                cell_K.setCellValue(targetTerms);
                cell_K.setCellStyle(style);
                p_sheet.setColumnWidth(col - 1, 30 * 256);
                p_row++;
            }
        }
        // Add category failure drop down list here.
        addCategoryFailureValidation(p_sheet, SEGMENT_START_ROW, p_row, CATEGORY_FAILURE_COLUMN,
                CATEGORY_FAILURE_COLUMN);
    }

    return p_row;
}

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

License:Apache License

private void addTitle(Workbook p_workbook, Sheet p_sheet) throws Exception {
    Font titleFont = p_workbook.createFont();
    titleFont.setUnderline(Font.U_NONE);
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    titleFont.setColor(IndexedColors.BLACK.getIndex());
    CellStyle titleStyle = p_workbook.createCellStyle();
    titleStyle.setWrapText(false);/* www  .j  av a  2s  .  c  om*/
    titleStyle.setFont(titleFont);

    Row titleRow = getRow(p_sheet, 0);
    Cell titleCell = getCell(titleRow, 0);
    titleCell.setCellValue(EMEA + " " + bundle.getString("lb_reviewer_po"));
    titleCell.setCellStyle(titleStyle);
    p_sheet.setColumnWidth(0, 20 * 256);
}

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

License:Apache License

/**
 * Adds the table header for the Dell Matches sheet
 * //  w w  w . j ava2 s .c  o m
 */
private void addHeaderForDellMatches(Workbook p_workbook) throws Exception {
    Sheet theSheet = data.dellSheet;
    int c = 0;
    Row headerRow = getRow(theSheet, 2);
    Cell cell_A = getCell(headerRow, c);
    cell_A.setCellValue(bundle.getString("lb_job_id"));
    cell_A.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_B = getCell(headerRow, c);
    cell_B.setCellValue(bundle.getString("lb_job_name"));
    cell_B.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_C = getCell(headerRow, c);
    cell_C.setCellValue(bundle.getString("lb_po_number_report"));
    cell_C.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    theSheet.setColumnWidth(c, 15 * 256);
    c++;
    Cell cell_D = getCell(headerRow, c);
    cell_D.setCellValue(bundle.getString("lb_description"));
    cell_D.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    theSheet.setColumnWidth(c, 15 * 256);
    c++;
    Cell cell_E = getCell(headerRow, c);
    cell_E.setCellValue(bundle.getString("lb_creation_date"));
    cell_E.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_F = getCell(headerRow, c);
    cell_F.setCellValue(bundle.getString("lb_activity_name"));
    cell_F.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    theSheet.setColumnWidth(c, 20 * 256);
    c++;
    Cell cell_G = getCell(headerRow, c);
    cell_G.setCellValue(bundle.getString("lb_accepted_reviewer_date"));
    cell_G.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    theSheet.setColumnWidth(c, 15 * 256);
    c++;
    Cell cell_H = getCell(headerRow, c);
    cell_H.setCellValue(bundle.getString("lb_lang"));
    cell_H.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_I = getCell(headerRow, c);
    cell_I.setCellValue(bundle.getString("lb_word_count"));
    cell_I.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    theSheet.setColumnWidth(c, 15 * 256);

    c++;
    Cell cell_J = getCell(headerRow, c);
    cell_J.setCellValue(bundle.getString("jobinfo.tmmatches.invoice"));
    cell_J.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_K = getCell(headerRow, c);
    cell_K.setCellValue(bundle.getString("lb_tracking"));
    cell_K.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
}

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

License:Apache License

/**
 * Adds the table header for the Trados Matches sheet
 * /*  www  .jav  a2  s .c  o m*/
 */
private void addHeaderForTradosMatches(Workbook p_workbook) throws Exception {
    Sheet theSheet = data.tradosSheet;
    int c = 0;
    Row secRow = getRow(theSheet, 1);
    Row thirRow = getRow(theSheet, 2);
    Row fourRow = getRow(theSheet, 3);

    Cell cell_Ldfl = getCell(secRow, 0);
    cell_Ldfl.setCellValue(bundle.getString("lb_desp_file_list"));
    cell_Ldfl.setCellStyle(getContentStyle(p_workbook));

    Cell cell_A = getCell(thirRow, c);
    cell_A.setCellValue(bundle.getString("lb_job_id"));
    cell_A.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_B = getCell(thirRow, c);
    cell_B.setCellValue(bundle.getString("lb_job"));
    cell_B.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_C = getCell(thirRow, c);
    cell_C.setCellValue(bundle.getString("lb_po_number_report"));
    cell_C.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_D = getCell(thirRow, c);
    cell_D.setCellValue(bundle.getString("lb_description"));
    cell_D.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    theSheet.setColumnWidth(c, 15 * 256);
    c++;
    Cell cell_E = getCell(thirRow, c);
    cell_E.setCellValue(bundle.getString("lb_creation_date"));
    cell_E.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_F = getCell(thirRow, c);
    cell_F.setCellValue(bundle.getString("lb_lang"));
    cell_F.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
    c++;
    Cell cell_G_Header = getCell(thirRow, c);
    cell_G_Header.setCellValue(bundle.getString("lb_word_counts"));
    cell_G_Header.setCellStyle(getHeaderStyle(p_workbook));

    if (data.headers[0] != null) {
        theSheet.addMergedRegion(new CellRangeAddress(2, 2, c, c + 7));
        setRegionStyle(theSheet, new CellRangeAddress(2, 2, c, c + 7), getHeaderStyle(p_workbook));
    } else {
        theSheet.addMergedRegion(new CellRangeAddress(2, 2, c, c + 6));
        setRegionStyle(theSheet, new CellRangeAddress(2, 2, c, c + 6), getHeaderStyle(p_workbook));
    }

    Cell cell_G = getCell(fourRow, c++);
    cell_G.setCellValue(bundle.getString("jobinfo.tradosmatches.invoice.per100matches"));
    cell_G.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_H = getCell(fourRow, c++);
    cell_H.setCellValue(bundle.getString("lb_95_99"));
    cell_H.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_I = getCell(fourRow, c++);
    cell_I.setCellValue(bundle.getString("lb_85_94"));
    cell_I.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_J = getCell(fourRow, c++);
    cell_J.setCellValue(bundle.getString("lb_75_84") + "*");
    cell_J.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_K = getCell(fourRow, c++);
    cell_K.setCellValue(bundle.getString("lb_no_match"));
    cell_K.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_L = getCell(fourRow, c++);
    cell_L.setCellValue(bundle.getString("lb_repetition_word_cnt"));
    cell_L.setCellStyle(getHeaderStyle(p_workbook));
    if (data.headers[0] != null) {
        Cell cell_InContext = getCell(fourRow, c++);
        cell_InContext.setCellValue(bundle.getString("lb_in_context_tm"));
        cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
    }
    Cell cell_Total = getCell(fourRow, c++);
    cell_Total.setCellValue(bundle.getString("lb_total"));
    cell_Total.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_Invoice = getCell(thirRow, c);
    cell_Invoice.setCellValue(bundle.getString("jobinfo.tmmatches.invoice"));
    cell_Invoice.setCellStyle(getHeaderStyle(p_workbook));

    if (data.headers[0] != null) {
        theSheet.addMergedRegion(new CellRangeAddress(2, 2, c, c + 9));
        setRegionStyle(theSheet, new CellRangeAddress(2, 2, c, c + 9), getHeaderStyle(p_workbook));
    } else {
        theSheet.addMergedRegion(new CellRangeAddress(2, 2, c, c + 8));
        setRegionStyle(theSheet, new CellRangeAddress(2, 2, c, c + 8), getHeaderStyle(p_workbook));
    }

    Cell cell_Per100Matches = getCell(fourRow, c++);
    cell_Per100Matches.setCellValue(bundle.getString("jobinfo.tradosmatches.invoice.per100matches"));
    cell_Per100Matches.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_95_99 = getCell(fourRow, c++);
    cell_95_99.setCellValue(bundle.getString("lb_95_99"));
    cell_95_99.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_85_94 = getCell(fourRow, c++);
    cell_85_94.setCellValue(bundle.getString("lb_85_94"));
    cell_85_94.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_75_84 = getCell(fourRow, c++);
    cell_75_84.setCellValue(bundle.getString("lb_75_84") + "*");
    cell_75_84.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_NoMatch = getCell(fourRow, c++);
    cell_NoMatch.setCellValue(bundle.getString("lb_no_match"));
    cell_NoMatch.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_Repetition = getCell(fourRow, c++);
    cell_Repetition.setCellValue(bundle.getString("lb_repetition_word_cnt"));
    cell_Repetition.setCellStyle(getHeaderStyle(p_workbook));
    if (data.headers[0] != null) {
        Cell cell_InContext = getCell(fourRow, c++);
        cell_InContext.setCellValue(bundle.getString("lb_in_context_tm"));
        cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
    }

    Cell cell_Total_Invoice = getCell(fourRow, c++);
    cell_Total_Invoice.setCellValue(bundle.getString("lb_translation_total"));
    cell_Total_Invoice.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_Review = getCell(fourRow, c++);
    cell_Review.setCellValue(bundle.getString("lb_review"));
    cell_Review.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_JobTotal = getCell(fourRow, c++);
    cell_JobTotal.setCellValue(bundle.getString("jobinfo.tmmatches.invoice.jobtotal"));
    cell_JobTotal.setCellStyle(getHeaderStyle(p_workbook));

    Cell cell_Tracking = getCell(thirRow, c);
    cell_Tracking.setCellValue(bundle.getString("lb_tracking"));
    cell_Tracking.setCellStyle(getHeaderStyle(p_workbook));
    theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
    setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook));
}

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

License:Apache License

private void writeProjectDataForDellMatches(Workbook p_workbook, HashMap p_projectMap, IntHolder p_row)
        throws Exception {
    Sheet theSheet = data.dellSheet;
    ArrayList projects = new ArrayList(p_projectMap.keySet());
    SortUtil.sort(projects);//from  ww  w.  ja va  2s  .c o  m
    Iterator projectIter = projects.iterator();

    while (projectIter.hasNext()) {
        String jobName = (String) projectIter.next();
        boolean isWrongJob = data.wrongJobNames.contains(jobName);
        HashMap localeMap = (HashMap) p_projectMap.get(jobName);
        ArrayList locales = new ArrayList(localeMap.keySet());
        SortUtil.sort(locales);
        Iterator localeIter = locales.iterator();

        while (localeIter.hasNext()) {
            int row = p_row.getValue();
            Row theRow = getRow(theSheet, row);
            int col = 0;
            String localeName = (String) localeIter.next();
            ProjectWorkflowData data = (ProjectWorkflowData) localeMap.get(localeName);

            // Job Id
            // Job Name
            Cell cell_A = getCell(theRow, col++);
            cell_A.setCellValue(data.jobId);
            Cell cell_B = getCell(theRow, col++);
            cell_B.setCellValue(data.jobName);
            if (isWrongJob) {
                cell_A.setCellStyle(getWrongJobStyle(p_workbook));
                cell_B.setCellStyle(getWrongJobStyle(p_workbook));
            } else {
                cell_A.setCellStyle(getContentStyle(p_workbook));
                cell_B.setCellStyle(getContentStyle(p_workbook));
            }
            theSheet.setColumnWidth(col - 2, 5 * 256);
            theSheet.setColumnWidth(col - 1, 50 * 256);

            // PO Number
            Cell cell_C = getCell(theRow, col++);
            cell_C.setCellValue("");
            cell_C.setCellStyle(getContentStyle(p_workbook));

            // Description
            Cell cell_D = getCell(theRow, col++);
            cell_D.setCellValue(data.projectDesc);
            cell_D.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, 22 * 256);

            // Create Date
            Cell cell_E = getCell(theRow, col++);
            cell_E.setCellValue(data.creationDate);
            cell_E.setCellStyle(getDateStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, 15 * 256);

            Cell cell_F = getCell(theRow, col++);
            cell_F.setCellValue(data.currentActivityName);
            cell_F.setCellStyle(getContentStyle(p_workbook));

            // Accepted Reviewer Date
            Cell cell_G = getCell(theRow, col++);
            if (data.dellReviewActivityState == Task.STATE_REJECTED) {
                cell_G.setCellValue(bundle.getString("lb_rejected"));
                cell_G.setCellStyle(getContentStyle(p_workbook));
            } else if (data.acceptedReviewerDate == null) {
                cell_G.setCellValue(bundle.getString("lb_not_accepted"));
                cell_G.setCellStyle(getContentStyle(p_workbook));
            } else {
                cell_G.setCellValue(data.acceptedReviewerDate);
                cell_G.setCellStyle(getDateStyle(p_workbook));
            }
            theSheet.setColumnWidth(col - 1, 22 * 256);

            // Lang
            Cell cell_H = getCell(theRow, col++);
            cell_H.setCellValue(data.targetLang);
            cell_H.setCellStyle(getContentStyle(p_workbook));

            // Word Count
            Cell cell_I = getCell(theRow, col++);
            cell_I.setCellValue(data.dellTotalWordCount);
            cell_I.setCellStyle(getContentStyle(p_workbook));

            // Invoice
            Cell cell_J = getCell(theRow, col++);
            if ((data.dellReviewActivityState == Task.STATE_REJECTED) || (data.acceptedReviewerDate == null)) {
                cell_J.setCellValue(0);
                cell_J.setCellStyle(getMoneyStyle(p_workbook));
            } else {
                cell_J.setCellValue(asDouble(data.dellTotalWordCountCostForDellReview));
                cell_J.setCellStyle(getMoneyStyle(p_workbook));
            }

            p_row.inc();
        }
    }

    p_row.inc();
    p_row.inc();
    addTotalsForDellMatches(p_workbook, p_row);
}

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

License:Apache License

private void writeProjectDataForTradosMatches(Workbook p_workbook, HashMap p_projectMap, IntHolder p_row)
        throws Exception {
    Sheet theSheet = data.tradosSheet;
    ArrayList projects = new ArrayList(p_projectMap.keySet());
    SortUtil.sort(projects);//from w w w. j  a  v a2  s .  c  om
    Iterator projectIter = projects.iterator();

    while (projectIter.hasNext()) {
        String jobName = (String) projectIter.next();
        boolean isWrongJob = data.wrongJobNames.contains(jobName);
        HashMap localeMap = (HashMap) p_projectMap.get(jobName);
        ArrayList locales = new ArrayList(localeMap.keySet());
        SortUtil.sort(locales);
        HashMap<String, String> jobLocale = new HashMap<String, String>();
        Iterator localeIter = locales.iterator();
        while (localeIter.hasNext()) {
            int row = p_row.getValue();
            int col = 0;
            Row theRow = getRow(theSheet, row);
            String localeName = (String) localeIter.next();
            ProjectWorkflowData data = (ProjectWorkflowData) localeMap.get(localeName);

            if (jobLocale.size() != 0 && jobLocale.get(jobName + data.targetLang) != null) {
                continue;
            } else {
                jobLocale.put(jobName + data.targetLang, jobName + data.targetLang);
            }
            Cell cell_A = getCell(theRow, col++);
            cell_A.setCellValue(data.jobId);
            Cell cell_B = getCell(theRow, col++);
            cell_B.setCellValue(data.jobName);
            if (isWrongJob) {
                cell_A.setCellStyle(getWrongJobStyle(p_workbook));
                cell_B.setCellStyle(getWrongJobStyle(p_workbook));
            } else {
                cell_A.setCellStyle(getContentStyle(p_workbook));
                cell_B.setCellStyle(getContentStyle(p_workbook));
            }
            theSheet.setColumnWidth(col - 2, 5 * 256);
            theSheet.setColumnWidth(col - 1, 50 * 256);
            Cell cell_C = getCell(theRow, col++);// PO number
            cell_C.setCellValue("");
            cell_C.setCellStyle(getContentStyle(p_workbook));

            Cell cell_D = getCell(theRow, col++);
            cell_D.setCellValue(data.projectDesc);
            cell_D.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, 22 * 256);
            /* data.creationDate.toString())); */
            Cell cell_E = getCell(theRow, col++);
            cell_E.setCellValue(data.creationDate);
            cell_E.setCellStyle(getDateStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, 15 * 256);

            Cell cell_F = getCell(theRow, col++);
            cell_F.setCellValue(data.targetLang);
            cell_F.setCellStyle(getContentStyle(p_workbook));

            Cell cell_G = getCell(theRow, col++);
            cell_G.setCellValue(data.trados100WordCount);
            cell_G.setCellStyle(getContentStyle(p_workbook));
            int numwidth = 10;
            theSheet.setColumnWidth(col - 1, numwidth * 256);

            Cell cell_H = getCell(theRow, col++);
            cell_H.setCellValue(data.trados95to99WordCount);
            cell_H.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, numwidth * 256);

            Cell cell_I = getCell(theRow, col++);
            cell_I.setCellValue(data.trados85to94WordCount);
            cell_I.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, numwidth * 256);

            Cell cell_J = getCell(theRow, col++);
            cell_J.setCellValue(data.trados75to84WordCount);
            cell_J.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, numwidth * 256);

            Cell cell_K = getCell(theRow, col++);
            cell_K.setCellValue(data.tradosNoMatchWordCount);
            cell_K.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, numwidth * 256);

            Cell cell_L = getCell(theRow, col++);
            cell_L.setCellValue(data.tradosRepsWordCount);
            cell_L.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, numwidth * 256);
            if (this.data.headers[0] != null) {
                Cell cell_InContext = getCell(theRow, col++);
                cell_InContext.setCellValue(data.tradosInContextWordCount);
                cell_InContext.setCellStyle(getContentStyle(p_workbook));
                theSheet.setColumnWidth(col - 1, numwidth * 256);
            }

            Cell cell_Total = getCell(theRow, col++);
            cell_Total.setCellValue(data.tradosTotalWordCount);
            cell_Total.setCellStyle(getContentStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, numwidth * 256);

            int moneywidth = 12;
            Cell cell_100Cost = getCell(theRow, col++);
            cell_100Cost.setCellValue(asDouble(data.trados100WordCountCost));
            cell_100Cost.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_95_99 = getCell(theRow, col++);
            cell_95_99.setCellValue(asDouble(data.trados95to99WordCountCost));
            cell_95_99.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_85_94 = getCell(theRow, col++);
            cell_85_94.setCellValue(asDouble(data.trados85to94WordCountCost));
            cell_85_94.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_75_84 = getCell(theRow, col++);
            cell_75_84.setCellValue(asDouble(data.trados75to84WordCountCost));
            cell_75_84.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_NoMatch = getCell(theRow, col++);
            cell_NoMatch.setCellValue(asDouble(data.tradosNoMatchWordCountCost));
            cell_NoMatch.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_Reps = getCell(theRow, col++);
            cell_Reps.setCellValue(asDouble(data.tradosRepsWordCountCost));
            cell_Reps.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);
            if (this.data.headers[0] != null) {
                Cell cell_InContext = getCell(theRow, col++);
                cell_InContext.setCellValue(asDouble(data.tradosInContextWordCountCost));
                cell_InContext.setCellStyle(getMoneyStyle(p_workbook));
                theSheet.setColumnWidth(col - 1, moneywidth * 256);
            }

            // theSheet.addCell(new
            // Number(col++,row,asDouble(data.tradosTotalWordCountCost),moneyFormat));
            // theSheet.setColumnView(col -1,moneywidth);
            Cell cell_Translation = getCell(theRow, col++);
            cell_Translation.setCellValue(asDouble(data.tradosTotalWordCountCostForTranslation));
            cell_Translation.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_Review = getCell(theRow, col++);
            cell_Review.setCellValue(asDouble(data.tradosTotalWordCountCostForDellReview));
            cell_Review.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_JobTotal = getCell(theRow, col++);
            cell_JobTotal.setCellValue(asDouble(data.tradosTotalWordCountCost));
            cell_JobTotal.setCellStyle(getMoneyStyle(p_workbook));
            theSheet.setColumnWidth(col - 1, moneywidth * 256);

            p_row.inc();
        }
    }

    p_row.inc();
    p_row.inc();
    addTotalsForTradosMatches(p_workbook, p_row);
}