List of usage examples for org.apache.poi.ss.usermodel Workbook createSheet
Sheet createSheet(String sheetname);
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
/** * Write report data info workbook in cache to output to file later. * @param p_workbook/*from w w w.jav a 2 s . com*/ * @param task * @throws Exception */ private void createReport(Workbook p_workbook, Task task) throws Exception { GlobalSightLocale trgLocale = task.getTargetLocale(); GlobalSightLocale srgLocale = task.getSourceLocale(); // Create Sheet Sheet sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add hidden info "DITA_taskID" for uploading. addHidenInfoForUpload(p_workbook, sheet, task.getId()); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add language header information String srcLang = srgLocale.getDisplayName(m_uiLocale); String trgLang = trgLocale.getDisplayName(m_uiLocale); writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); // Add Segment Header addSegmentHeader(p_workbook, sheet); // write data into report writeSegmentInfo(p_workbook, sheet, task); }
From source file:com.globalsight.everest.qachecks.QAChecker.java
License:Apache License
public String runQAChecksAndGenerateReport(long taskId) throws Exception { Task task = ServerProxy.getTaskManager().getTask(taskId); Company company = CompanyWrapper.getCompanyById(task.getCompanyId()); if (!company.getEnableQAChecks()) { return null; }//ww w.j a v a 2 s . co m Workflow workflow = task.getWorkflow(); GlobalSightLocale targetLocale = workflow.getTargetLocale(); GlobalSightLocale sourceLocale = workflow.getJob().getSourceLocale(); String srcLang = sourceLocale.getDisplayName(m_uiLocale); String trgLang = targetLocale.getDisplayName(m_uiLocale); logger.info("Running QA Checks and generating report on " + task.getTaskDisplayName() + "[" + sourceLocale.toString() + "_" + targetLocale.toString() + "]."); Workbook workbook = new SXSSFWorkbook(); Sheet sheet = workbook.createSheet(targetLocale.toString()); sheet.protectSheet(""); addTitle(workbook, sheet); addHiddenInfoForUpload(workbook, sheet, taskId); addLanguageHeader(workbook, sheet); writeLanguageInfo(workbook, sheet, srcLang, trgLang); addSegmentHeader(workbook, sheet); boolean hasErrors = writeSegmentInfo(workbook, sheet, workflow); String reportPath = saveReportFile(workbook, task); if (hasErrors) { logger.info("Done QA Checks, report " + reportPath + " is saved."); } else { logger.info("Done QA Checks, no issues reported. Report " + reportPath + " is saved."); } return reportPath; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.CommentXlsReportHelper.java
License:Apache License
private void createSheets(HttpServletRequest p_request, Workbook p_workbook, HttpServletResponse p_response) throws Exception { Sheet segmentSheet = null;/* w w w .j a v a 2 s .c o m*/ Sheet jobSheet = null; Sheet taskSheet = null; HashMap<String, Sheet> sheetMap = new HashMap<String, Sheet>(); String[] paramCommentTypeJob = p_request.getParameterValues("commentType_Job"); String[] paramCommentTypeTask = p_request.getParameterValues("commentType_Activity"); segmentSheet = p_workbook.createSheet(bundle.getString("segment_comments")); addTitle(p_workbook, segmentSheet, bundle.getString("segment_comments")); addHeader(p_workbook, segmentSheet); sheetMap.put("segmentSheet", segmentSheet); if ((paramCommentTypeJob != null) && ("Job".equals(paramCommentTypeJob[0]) == true)) { if (oneSheet == true) { jobSheet = segmentSheet; } else { jobSheet = p_workbook.createSheet(bundle.getString("job_comments")); addTitle(p_workbook, jobSheet, bundle.getString("job_comments")); addHeader(p_workbook, jobSheet); } sheetMap.put("jobSheet", jobSheet); } if ((paramCommentTypeTask != null) && ("Activity".equals(paramCommentTypeTask[0]) == true)) { if (oneSheet == true) { taskSheet = segmentSheet; } else { taskSheet = p_workbook.createSheet(bundle.getString("activity_comments")); addTitle(p_workbook, taskSheet, bundle.getString("activity_comments")); addHeader(p_workbook, taskSheet); } sheetMap.put("taskSheet", taskSheet); } addComments(p_workbook, p_request, sheetMap, p_response); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CharacterCountReportGenerator.java
License:Apache License
/** * Create one excel file report per job. Within each excel spreadsheet, use * one tab per target language./*ww w . j av a2s . co m*/ * * @param p_workbook * excel file * @param p_job * job * @param p_targetLangIDS * target language id list * @throws Exception */ private void createReport(Workbook p_workbook, Job p_job, List<GlobalSightLocale> p_targetLangIDS) throws Exception { List<GlobalSightLocale> jobTL = ReportHelper.getTargetLocals(p_job); for (GlobalSightLocale trgLocale : p_targetLangIDS) { if (!jobTL.contains(trgLocale)) continue; // Create One Report Sheet/Tab Sheet sheet = p_workbook.createSheet(trgLocale.toString()); // add title addTitle(p_workbook, sheet); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Write Language Information String srcLang = p_job.getSourceLocale().getDisplayName(m_uiLocale); String trgLang = trgLocale.getDisplayName(m_uiLocale); writeLanguageInfo(p_workbook, sheet, srcLang, trgLang, p_job); // Write Segments Information writeCharacterCountSegmentInfo(p_workbook, sheet, p_job, trgLocale, "", SEGMENT_START_ROW); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CommentsAnalysisReportGenerator.java
License:Apache License
/** * Create the report sheets//w ww . ja v a 2 s . c o m * * @throws Exception */ private void createReport(Workbook p_workbook, Job p_job, List<GlobalSightLocale> p_targetLocales, String p_dateFormat) throws Exception { List<GlobalSightLocale> jobTL = ReportHelper.getTargetLocals(p_job); for (GlobalSightLocale trgLocale : p_targetLocales) { if (!jobTL.contains(trgLocale)) continue; String srcLang = p_job.getSourceLocale().getDisplayName(uiLocale); String trgLang = trgLocale.getDisplayName(uiLocale); // Create One Report Sheet/Tab Sheet sheet = null; if (isCombineAllJobs && p_workbook.getSheet(trgLocale.toString()) != null) { sheet = p_workbook.getSheet(trgLocale.toString()); } else { sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Insert Language Data writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); } // Create Name Areas for drop down list. if (p_workbook.getName(CATEGORY_FAILURE_DROP_DOWN_LIST) == null) { createCategoryFailureNameArea(p_workbook); } // Insert Segment Data if (isCombineAllJobs) { Integer row = null; if (rowsMap.get(trgLang) == null) { row = writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, p_dateFormat, SEGMENT_START_ROW); } else { row = writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, p_dateFormat, rowsMap.get(trgLang)); } rowsMap.put(trgLang, row); } else { writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, p_dateFormat, SEGMENT_START_ROW); } } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CommentsAnalysisReportGenerator.java
License:Apache License
private void addCriteriaSheet(Workbook p_workbook, List<Job> p_jobsList, Set<String> stateSet, Set<String> projectSet) throws Exception { Sheet sheet = p_workbook.createSheet(bundle.getString("lb_criteria")); StringBuffer temp = new StringBuffer(); int row = 0;/*from w w w. ja va2s. co m*/ int headerColumn = 1; int valueColumn = 2; Row targetLocalesRow = getRow(sheet, row++); Row statusRow = getRow(sheet, row++); Row projectRow = getRow(sheet, row++); Row dateRangeRow = getRow(sheet, row++); Row jobsRow = getRow(sheet, row); Cell cell_TargetLocales = getCell(targetLocalesRow, headerColumn); cell_TargetLocales.setCellValue(bundle.getString("lb_report_target_locales")); cell_TargetLocales.setCellStyle(getContentStyle(p_workbook)); sheet.setColumnWidth(headerColumn, 20 * 256); Cell cell_Status = getCell(statusRow, headerColumn); cell_Status.setCellValue(bundle.getString("job_status")); cell_Status.setCellStyle(getContentStyle(p_workbook)); Cell cell_Project = getCell(projectRow, headerColumn); cell_Project.setCellValue(bundle.getString("lb_report_project")); cell_Project.setCellStyle(getContentStyle(p_workbook)); Cell cell_DateRange = getCell(dateRangeRow, headerColumn); cell_DateRange.setCellValue(bundle.getString("lb_report_date_range")); cell_DateRange.setCellStyle(getContentStyle(p_workbook)); Cell cell_Jobs = getCell(jobsRow, headerColumn); cell_Jobs.setCellValue(bundle.getString("lb_jobs")); cell_Jobs.setCellStyle(getContentStyle(p_workbook)); //locale Set<String> localeSet = rowsMap.keySet(); for (String locale : localeSet) { temp.append(locale + "\n"); } Cell cell_TargetLocalesValue = getCell(targetLocalesRow, valueColumn); cell_TargetLocalesValue.setCellValue(temp.substring(0, temp.length() - 1)); cell_TargetLocalesValue.setCellStyle(getContentStyle(p_workbook)); sheet.setColumnWidth(valueColumn, 45 * 256); //status temp.setLength(0); for (String status : stateSet) { temp.append(status + "\n"); } Cell cell_StatusValue = getCell(statusRow, valueColumn); cell_StatusValue.setCellValue(temp.substring(0, temp.length() - 1)); cell_StatusValue.setCellStyle(getContentStyle(p_workbook)); //project temp.setLength(0); for (String status : projectSet) { temp.append(status + "\n"); } Cell cell_ProjectValue = getCell(projectRow, valueColumn); cell_ProjectValue.setCellValue(temp.substring(0, temp.length() - 1)); cell_ProjectValue.setCellStyle(getContentStyle(p_workbook)); //date range temp.setLength(0); String startCount = request.getParameter(JobSearchConstants.CREATION_START); if (startCount != null && startCount != "") { temp.append("Starts:" + startCount + "\n"); } String endCount = request.getParameter(JobSearchConstants.CREATION_END); if (endCount != null && endCount != "") { temp.append("Ends:" + endCount); } Cell cell_DateRangeValue = getCell(dateRangeRow, valueColumn); cell_DateRangeValue.setCellValue(temp.toString()); cell_DateRangeValue.setCellStyle(getContentStyle(p_workbook)); //jobs int jobRowNum = 4; for (Job job : p_jobsList) { Cell cell_JobValue = getCell(getRow(sheet, jobRowNum++), valueColumn); cell_JobValue.setCellValue(job.getJobId() + "," + job.getJobName()); cell_JobValue.setCellStyle(getContentStyle(p_workbook)); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ImplementedCommentsCheckReportGenerator.java
License:Apache License
/** * Create the report sheets/*from w w w . ja va2 s .c o m*/ * * @throws Exception */ private void createReport(Workbook p_workbook, Job p_job, List<GlobalSightLocale> p_targetLocales, String p_dateFormat) throws Exception { List<GlobalSightLocale> jobTL = ReportHelper.getTargetLocals(p_job); for (GlobalSightLocale trgLocale : p_targetLocales) { if (!jobTL.contains(trgLocale)) continue; String srcLang = p_job.getSourceLocale().getDisplayName(uiLocale); String trgLang = trgLocale.getDisplayName(uiLocale); // Create One Report Sheet/Tab Sheet sheet = null; if (p_workbook.getSheet(trgLocale.toString()) != null) { sheet = p_workbook.getSheet(trgLocale.toString()); } else { sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Insert Language Data writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); } // Create Name Areas for drop down list. if (p_workbook.getName(CATEGORY_FAILURE_DROP_DOWN_LIST) == null) { createCategoryFailureNameArea(p_workbook); } writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, p_dateFormat, SEGMENT_START_ROW); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
/** * Generates the Excel report as a temp file and returns the temp file. The * report consists of all jobs for the given PM, this year, on a month by * month basis.//from w ww .j a v a 2 s . c om * * @return File * @exception Exception */ private File[] generateReport(HttpServletRequest p_request) throws Exception { String[] months = getMonths(); File file = ReportHelper.getXLSReportFile(getReportType(), null); Workbook p_workbook = new SXSSFWorkbook(); int currentMonth = m_calendar.get(Calendar.MONTH); int year; if (p_request.getParameter("year") != null) { year = Integer.parseInt(p_request.getParameter("year")); } else { year = m_calendar.get(Calendar.YEAR); } if (year != m_calendar.get(Calendar.YEAR)) currentMonth = 11; boolean wroteSomething = false; boolean recalculateFinishedWorkflow = false; String recalcParam = p_request.getParameter("recalc"); if (recalcParam != null && recalcParam.length() > 0) { recalculateFinishedWorkflow = java.lang.Boolean.valueOf(recalcParam).booleanValue(); } // For "Dell Review Report Issue" // Gets the tag that marks whether needs to separates "Dell_Review" or // not. // Default value is "false". boolean includeExReview = false; String reviewParam = p_request.getParameter("review"); if ((reviewParam != null) && (reviewParam.length() > 0)) { includeExReview = java.lang.Boolean.valueOf(reviewParam).booleanValue(); } // For "Add Job Id into online job report" issue isJobIdVisible = isJobIdVisible(p_request); String isReportForYear = p_request.getParameter("reportForThisYear"); String isReportForDetail = p_request.getParameter("reportForDetail"); // Generate Report By Year if (isReportForYear != null && isReportForYear.equals("on")) { int i = 0; for (i = 0; i <= currentMonth; i++) { // For "Dell Review Report Issue" // Add new parameter "includeExReview" to the signature. HashMap<String, HashMap<String, ProjectWorkflowData>> projectMap = getProjectDataForMonth(p_request, i, recalculateFinishedWorkflow, includeExReview); // Cancel the report. if (isCancelled()) return new File[0]; if (projectMap.size() > 0) { // This sheets array has two elements. // sheets[MONTH_SHEET], the original monthSheet. // sheets[MONTH_REVIEW_SHEET], new monthly Dell_Review // sheet. Sheet[] sheets = new Sheet[2]; IntHolder[] rows = new IntHolder[2]; String sheetTitle = months[i] + " " + year; sheets[MONTH_SHEET] = p_workbook.createSheet(sheetTitle); // m_data.isTradosStyle by default is true, matches trados for UI is hidden if (m_data.isTradosStyle()) { addTitle(p_workbook, sheets[MONTH_SHEET]); addHeaderTradosStyle(p_workbook, sheets[MONTH_SHEET], MONTH_SHEET); } else { addTitle(p_workbook, sheets[MONTH_SHEET]); addHeader(p_workbook, sheets[MONTH_SHEET], MONTH_SHEET); } rows[MONTH_SHEET] = new IntHolder(4); if (includeExReview) { String sheetReviewTitle = m_bundle.getString("lb_review") + " " + months[i] + " " + year; sheets[MONTH_REVIEW_SHEET] = p_workbook.createSheet(sheetReviewTitle); if (m_data.isTradosStyle()) { addTitle(p_workbook, sheets[MONTH_REVIEW_SHEET]); addHeaderTradosStyle(p_workbook, sheets[MONTH_REVIEW_SHEET], MONTH_REVIEW_SHEET); } else { addTitle(p_workbook, sheets[MONTH_REVIEW_SHEET]); addHeader(p_workbook, sheets[MONTH_REVIEW_SHEET], MONTH_REVIEW_SHEET); } rows[MONTH_REVIEW_SHEET] = new IntHolder(4); } if (m_data.isTradosStyle()) { writeProjectDataTradosStyle(projectMap, p_workbook, sheets, includeExReview, rows); } else { writeProjectData(projectMap, p_workbook, sheets, includeExReview, rows); } wroteSomething = true; } } if (!wroteSomething) { // just write out the first sheet to avoid Excel problems i = 0; String sheetTitle = months[currentMonth] + " " + year; Sheet monthSheet = p_workbook.createSheet(sheetTitle); if (m_data.isTradosStyle()) { addTitle(p_workbook, monthSheet); addHeaderTradosStyle(p_workbook, monthSheet, MONTH_SHEET); } else { addTitle(p_workbook, monthSheet); addHeader(p_workbook, monthSheet, MONTH_SHEET); } if (includeExReview) { String sheetReviewTitle = "Review " + months[currentMonth] + " " + year; Sheet monthReviewSheet = p_workbook.createSheet(sheetReviewTitle); if (m_data.isTradosStyle()) { addTitle(p_workbook, monthReviewSheet); addHeaderTradosStyle(p_workbook, monthReviewSheet, MONTH_REVIEW_SHEET); } else { addTitle(p_workbook, monthReviewSheet); addHeader(p_workbook, monthReviewSheet, MONTH_REVIEW_SHEET); } } } // Create "Criteria" Sheet addParamsSheet(p_workbook, (String) p_request.getParameter("year"), recalculateFinishedWorkflow); FileOutputStream out = new FileOutputStream(file); p_workbook.write(out); out.close(); ((SXSSFWorkbook) p_workbook).dispose(); } // Generate Report by Creation Date Range. else if (isReportForDetail != null && isReportForDetail.endsWith("on")) { // For "Dell Review Report Issue" // Add new parameter "includeExReview" to the signature. HashMap<String, HashMap<String, ProjectWorkflowData>> projectMap = getProjectDataForMonth(p_request, 0, recalculateFinishedWorkflow, includeExReview); // Cancel the report. if (isCancelled()) return new File[0]; // Create sheets in Workbook. createSheets(p_workbook, projectMap, includeExReview); // Create "Criteria" Sheet addParamsSheet(p_workbook, (String) p_request.getParameter("year"), recalculateFinishedWorkflow); FileOutputStream out = new FileOutputStream(file); p_workbook.write(out); out.close(); ((SXSSFWorkbook) p_workbook).dispose(); } List<File> workBooks = new ArrayList<File>(); workBooks.add(file); return ReportHelper.moveReports(workBooks, m_userId); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
/** * Create sheets in Workbook, include 2 sheets by Creation Date Range. The * sheets are the original month Sheet("Detail Report") and monthly * Dell_Review sheet("Review Detail Report"). *//*from w w w. ja v a 2s.c o m*/ private void createSheets(Workbook p_workbook, HashMap<String, HashMap<String, ProjectWorkflowData>> p_projectMap, boolean p_includeExReview) throws Exception { if (p_projectMap.size() > 0) { // This sheets array has two elements. // sheets[MONTH_SHEET], the original month Sheet("Detail Report"). // sheets[MONTH_REVIEW_SHEET], new monthly Dell_Review // sheet("Review Detail Report"). Sheet[] sheets = new Sheet[2]; IntHolder[] rows = new IntHolder[2]; String sheetTitle = m_bundle.getString("lb_detail_report"); sheets[MONTH_SHEET] = p_workbook.createSheet(sheetTitle); if (m_data.isTradosStyle()) { addTitle(p_workbook, sheets[MONTH_SHEET]); addHeaderTradosStyle(p_workbook, sheets[MONTH_SHEET], MONTH_SHEET); } else { addTitle(p_workbook, sheets[MONTH_SHEET]); addHeader(p_workbook, sheets[MONTH_SHEET], MONTH_SHEET); } rows[MONTH_SHEET] = new IntHolder(4); if (p_includeExReview) { String sheetReviewTitle = m_bundle.getString("lb_review_detail_report"); sheets[MONTH_REVIEW_SHEET] = p_workbook.createSheet(sheetReviewTitle); if (m_data.isTradosStyle()) { addTitle(p_workbook, sheets[MONTH_REVIEW_SHEET]); addHeaderTradosStyle(p_workbook, sheets[MONTH_REVIEW_SHEET], MONTH_REVIEW_SHEET); } else { addTitle(p_workbook, sheets[MONTH_REVIEW_SHEET]); addHeader(p_workbook, sheets[MONTH_REVIEW_SHEET], MONTH_REVIEW_SHEET); } rows[MONTH_REVIEW_SHEET] = new IntHolder(4); } if (m_data.isTradosStyle()) { writeProjectDataTradosStyle(p_projectMap, p_workbook, sheets, p_includeExReview, rows); } else { writeProjectData(p_projectMap, p_workbook, sheets, p_includeExReview, rows); } } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java
License:Apache License
private void addParamsSheet(Workbook p_workbook, String year, boolean recalculateFinishedWorkflow) throws Exception { Sheet paramsSheet = p_workbook.createSheet(m_bundle.getString("lb_criteria")); Row firRow = getRow(paramsSheet, 0); Cell cell_A_Header = getCell(firRow, 0); cell_A_Header.setCellValue(m_bundle.getString("lb_report_criteria")); cell_A_Header.setCellStyle(getContentStyle(p_workbook)); paramsSheet.setColumnWidth(0, 50 * 256); Row secRow = getRow(paramsSheet, 1); Cell cell_A_Project = getCell(secRow, 0); if (m_data.wantsAllProjects) { cell_A_Project//from www .j av a 2s. co m .setCellValue(m_bundle.getString("lb_selected_projects") + " " + m_bundle.getString("all")); cell_A_Project.setCellStyle(getContentStyle(p_workbook)); } else { cell_A_Project.setCellValue(m_bundle.getString("lb_selected_projects")); cell_A_Project.setCellStyle(getContentStyle(p_workbook)); Iterator<Long> iter = m_data.projectIdList.iterator(); int r = 3; while (iter.hasNext()) { Long pid = (Long) iter.next(); String projectName = "??"; try { Project p = ServerProxy.getProjectHandler().getProjectById(pid.longValue()); projectName = p.getName(); } catch (Exception e) { } Row row = getRow(paramsSheet, r); Cell cell_A = getCell(row, 0); cell_A.setCellValue(projectName); cell_A.setCellStyle(getContentStyle(p_workbook)); Cell cell_B = getCell(row, 1); cell_B.setCellValue(m_bundle.getString("lb_id") + "=" + pid.toString()); cell_B.setCellStyle(getContentStyle(p_workbook)); r++; } } Cell cell_C_Header = getCell(firRow, 2); cell_C_Header.setCellValue(m_bundle.getString("lb_Year")); cell_C_Header.setCellStyle(getContentStyle(p_workbook)); Cell cell_C = getCell(secRow, 2); cell_C.setCellValue(year); cell_C.setCellStyle(getContentStyle(p_workbook)); Cell cell_D_Header = getCell(firRow, 3); cell_D_Header.setCellValue(m_bundle.getString("lb_re_cost_jobs")); cell_D_Header.setCellStyle(getContentStyle(p_workbook)); Cell cell_D = getCell(secRow, 3); cell_D.setCellValue(java.lang.Boolean.toString(recalculateFinishedWorkflow)); cell_D.setCellStyle(getContentStyle(p_workbook)); }