List of usage examples for org.apache.poi.ss.usermodel Sheet protectSheet
public void protectSheet(String password);
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 ww w.ja v a 2s .c o m*/ * @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; }//from w w w . java 2s . c om 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.generator.CommentsAnalysisReportGenerator.java
License:Apache License
/** * Create the report sheets// ww w.j a v a 2s.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.ImplementedCommentsCheckReportGenerator.java
License:Apache License
/** * Create the report sheets//from w w w . ja v a 2s .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.PostReviewQAReportGenerator.java
License:Apache License
/** * Create the report//from w ww . j a 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 { // Till now, only support one target locale. GlobalSightLocale trgLocale = p_targetLocales.get(0); // Create Sheet Sheet sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add hidden info "PRR_taskID" for uploading. addHidenInfoForUpload(p_workbook, sheet, p_job, trgLocale); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Quality Assessment addQuaAssessment(p_workbook, sheet); // Add Suitability for Market addSuitMarket(p_workbook, sheet); // Add Reviewer Comment addReviwerCommet(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Create Name Areas for drop down list. createCategoryFailureNameArea(p_workbook); createQualityAssessmentNameArea(p_workbook); createMarketSuitabilityNameArea(p_workbook); // Insert Data into Report String srcLang = p_job.getSourceLocale().getDisplayName(m_uiLocale); String trgLang = trgLocale.getDisplayName(m_uiLocale); writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); writeQualityAssessmentInfo(p_workbook, sheet, p_job, trgLocale); writeMarketSuitabilityInfo(p_workbook, sheet, p_job, trgLocale); writeReviewerComment(p_workbook, sheet); writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, "", p_dateFormat, SEGMENT_START_ROW); addQualityAssessmentValidation(sheet, 6, 6, 1, 1); addMarketSuitabilityValidation(sheet, 7, 7, 1, 1); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsReportGenerator.java
License:Apache License
/** * Create the report//ww w .ja v a2 s . c o m * * @throws Exception */ private void createReport(Workbook p_workbook, Job p_job, List<GlobalSightLocale> p_targetLocales, String p_dateFormat) throws Exception { boolean categoryFailureDropDownAdded = false; List<GlobalSightLocale> jobTL = ReportHelper.getTargetLocals(p_job); for (GlobalSightLocale trgLocale : p_targetLocales) { if (!jobTL.contains(trgLocale)) continue; if (cancel) return; // Create Report Template Sheet sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add hidden info "RCR_taskID" for uploading. addHidenInfoForUpload(p_workbook, sheet, p_job, trgLocale); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Create Name Areas for drop down list. if (!categoryFailureDropDownAdded) { createCategoryFailureNameArea(p_workbook); categoryFailureDropDownAdded = true; } // Insert Language Data String srcLang = p_job.getSourceLocale().getDisplayName(m_uiLocale); String trgLang = trgLocale.getDisplayName(m_uiLocale); writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); // Insert Segment Data writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, SEGMENT_START_ROW); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
/** * Create the report/*from www.ja v a2s. co m*/ * * @throws Exception */ private void createReport(Workbook p_workbook, Job p_job, List<GlobalSightLocale> p_targetLocales, String p_dateFormat) throws Exception { boolean categoryFailureDropDownAdded = false; List<GlobalSightLocale> jobTL = ReportHelper.getTargetLocals(p_job); for (GlobalSightLocale trgLocale : p_targetLocales) { if (!jobTL.contains(trgLocale)) continue; if (cancel) return; // Create Report Template Sheet sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add hidden info "RCSR_taskID" for uploading. addHidenInfoForUpload(p_workbook, sheet, p_job, trgLocale); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Create Name Areas for drop down list. if (!categoryFailureDropDownAdded) { createCategoryFailureNameArea(p_workbook); categoryFailureDropDownAdded = true; } // Insert Language Data String srcLang = p_job.getSourceLocale().getDisplayName(m_uiLocale); String trgLang = trgLocale.getDisplayName(m_uiLocale); writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); // Insert Segment Data writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, SEGMENT_START_ROW); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.TranslationsEditReportGenerator.java
License:Apache License
/** * Create the report/* www. j a v a 2 s. co m*/ * * @throws Exception */ private void createReport(Workbook p_workbook, Job p_job, List<GlobalSightLocale> p_targetLocales, String p_dateFormat) throws Exception { // Till now, only support one target locale. GlobalSightLocale trgLocale = p_targetLocales.get(0); // Create Sheet Sheet sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add hidden info "TER_taskID" for uploading. addHidenInfoForUpload(p_workbook, sheet, p_job, trgLocale); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Create Name Areas for drop down list. createCategoryFailureNameArea(p_workbook); // Insert Data into Report String srcLang = p_job.getSourceLocale().getDisplayName(m_uiLocale); String trgLang = trgLocale.getDisplayName(m_uiLocale); writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, "", p_dateFormat, SEGMENT_START_ROW); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.TranslationVerificationReportGenerator.java
License:Apache License
/** * Create the report//w w w . java2s . co m * * @throws Exception */ private void createReport(Workbook p_workbook, Job p_job, List<GlobalSightLocale> p_targetLocales, String p_dateFormat) throws Exception { // Till now, only support one target locale. GlobalSightLocale trgLocale = p_targetLocales.get(0); // Create Sheet Sheet sheet = p_workbook.createSheet(trgLocale.toString()); sheet.protectSheet(""); // Add Title addTitle(p_workbook, sheet); // Add hidden info "TVR_taskID" for uploading. addHidenInfoForUpload(p_workbook, sheet, p_job, trgLocale); // Add Locale Pair Header addLanguageHeader(p_workbook, sheet); // Add Segment Header addSegmentHeader(p_workbook, sheet); // Create Name Areas for drop down list. createCategoryFailureNameArea(p_workbook); // Insert Data into Report String srcLang = p_job.getSourceLocale().getDisplayName(m_uiLocale); String trgLang = trgLocale.getDisplayName(m_uiLocale); writeLanguageInfo(p_workbook, sheet, srcLang, trgLang); writeSegmentInfo(p_workbook, sheet, p_job, trgLocale, "", p_dateFormat, SEGMENT_START_ROW); }
From source file:Compras.generaCotizacion.java
void exel() { h = new Herramientas(this.user, 0); h.session(sessionPrograma);/*ww w. j a v a 2 s. com*/ javax.swing.JFileChooser jF1 = new javax.swing.JFileChooser(); jF1.setFileFilter(new ExtensionFileFilter("Excel document (*.xls)", new String[] { "xls" })); String ruta = null; if (jF1.showSaveDialog(null) == jF1.APPROVE_OPTION) { ruta = jF1.getSelectedFile().getAbsolutePath(); if (ruta != null) { if (ruta.endsWith(".xls") == true) archivoXLS = new File(ruta); else archivoXLS = new File(ruta + ".xls"); try { if (archivoXLS.exists()) archivoXLS.delete(); archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("Cotizacion"); Font font = libro.createFont(); font.setFontHeightInPoints((short) 24); font.setFontName("Arial"); font.setItalic(false); font.setBold(true); Font font10 = libro.createFont(); font10.setFontHeightInPoints((short) 10); font10.setFontName("Arial"); font10.setItalic(false); font10.setBold(false); font10.setColor(new HSSFColor.YELLOW().getIndex()); Font font11 = libro.createFont(); font11.setFontHeightInPoints((short) 10); font11.setFontName("Arial"); font10.setItalic(false); font10.setBold(false); font11.setColor(new HSSFColor.BLACK().getIndex()); // Fonts are set into a style so create a new one to use. CellStyle style = libro.createCellStyle(); CellStyle desBloqueo = libro.createCellStyle(); CellStyle desBloqueo1 = libro.createCellStyle(); CellStyle desBloqueoFecha = libro.createCellStyle(); style.setFont(font); desBloqueo.setFont(font10); desBloqueo.setLocked(false); desBloqueo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); desBloqueo.setFillBackgroundColor(new HSSFColor.GREEN().getIndex()); desBloqueo1.setFont(font11); desBloqueo1.setLocked(false); desBloqueo1.setFillBackgroundColor(new HSSFColor.WHITE().getIndex()); desBloqueoFecha.setFont(font10); desBloqueoFecha.setLocked(false); desBloqueoFecha.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); desBloqueoFecha.setFillBackgroundColor(new HSSFColor.GREEN().getIndex()); desBloqueoFecha.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy")); Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction().begin(); Orden ord = (Orden) session.get(Orden.class, Integer.parseInt(orden)); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); hoja.setColumnWidth(5, 15000); Row r0 = hoja.createRow(0); Cell celdaTitulo = r0.createCell(0); celdaTitulo.setCellValue(con.getEmpresa()); celdaTitulo.setCellStyle(style); Row r1 = hoja.createRow(1); r1.createCell(6).setCellValue("Orden de Taller:"); r1.createCell(7).setCellValue(orden); Row r2 = hoja.createRow(2); r2.createCell(0).setCellValue("Marca:"); r2.createCell(1).setCellValue(ord.getMarca().getMarcaNombre()); r2.createCell(6).setCellValue("N Serie:"); r2.createCell(7).setCellValue(ord.getNoSerie()); Row r3 = hoja.createRow(3); r3.createCell(0).setCellValue("Tipo:"); r3.createCell(1).setCellValue(ord.getTipo().getTipoNombre()); r3.createCell(6).setCellValue("N Motor:"); r3.createCell(7).setCellValue(ord.getNoMotor()); Row r4 = hoja.createRow(4); r4.createCell(0).setCellValue("NP:"); r4.createCell(1).setCellValue(t_datos1.getValueAt(t_datos1.getSelectedRow(), 1).toString()); r4.createCell(2).setCellValue("Proveedor:"); r4.createCell(3).setCellValue(t_datos1.getValueAt(t_datos1.getSelectedRow(), 2).toString()); r4.createCell(6).setCellValue("Modelo:"); r4.createCell(7).setCellValue("" + ord.getModelo()); Row r5 = hoja.createRow(5); r5.createCell(0).setCellValue( "**********************************************************************************[Nota: Solo puedes editar las celdas de color]*******************************************************************************"); Row r6 = hoja.createRow(6); r6.createCell(0).setCellValue("Partida"); r6.createCell(1).setCellValue("sub"); r6.createCell(2).setCellValue("Cantidad"); r6.createCell(3).setCellValue("U/Medida"); r6.createCell(4).setCellValue("N Parte"); r6.createCell(5).setCellValue("Descripcion"); r6.createCell(6).setCellValue("Instruccin"); r6.createCell(7).setCellValue("Precio c/u"); r6.createCell(8).setCellValue("T o t a l"); r6.createCell(9).setCellValue("Origen"); r6.createCell(10).setCellValue("Pazo"); Row r7 = hoja.createRow(7); r7.createCell(0).setCellValue( "**********************************************************************************************************************************************************************************************************************"); List misCotizaciones = null; Query query = session.createQuery("SELECT DISTINCT par FROM Partida par " + "RIGHT JOIN FETCH par.partidaCotizacions partC " + "RIGHT JOIN partC.cotizacion cot " + "where cot.idCotizacion=" + t_datos1.getValueAt(t_datos1.getSelectedRow(), 0).toString() + " order by par.idEvaluacion asc, par.subPartida asc"); //misCotizaciones=c.addOrder(Order.asc("idCotizacion")).list(); misCotizaciones = query.list(); if (misCotizaciones.size() > 0) { for (int i = 0; i < misCotizaciones.size(); i++) { Partida Part = (Partida) misCotizaciones.get(i); Row fila = hoja.createRow(i + 8); fila.createCell(0).setCellValue(Part.getIdEvaluacion()); fila.createCell(1).setCellValue(Part.getSubPartida()); fila.createCell(2).setCellValue(Part.getCant()); fila.createCell(3).setCellValue(Part.getMed()); Cell aux = fila.createCell(4); aux.setCellStyle(desBloqueo); if (Part.getEjemplar() != null) aux.setCellValue(Part.getEjemplar().getIdParte()); else aux.setCellValue(""); fila.createCell(5).setCellValue(Part.getCatalogo().getNombre()); int fil = i + 9; Cell a10 = fila.createCell(6); a10.setCellStyle(desBloqueo1); a10.setCellValue(Part.getInstruccion()); Cell a6 = fila.createCell(7); a6.setCellStyle(desBloqueo); a6.setCellValue(""); Cell celForm = fila.createCell(8); celForm.setCellType(HSSFCell.CELL_TYPE_FORMULA); celForm.setCellFormula("H" + fil + "*C" + fil); if (Part.isOri() == true) fila.createCell(9).setCellValue("Ori"); else if (Part.isNal() == true) fila.createCell(9).setCellValue("Nal"); else if (Part.isDesm() == true) fila.createCell(9).setCellValue("Des"); else fila.createCell(9).setCellValue(""); Cell a9 = fila.createCell(10); a9.setCellValue(""); a9.setCellStyle(desBloqueo); } } hoja.protectSheet("04650077"); libro.write(archivo); archivo.close(); Desktop.getDesktop().open(archivoXLS); if (session != null) if (session.isOpen()) session.close(); } catch (Exception e) { System.out.println(e); e.printStackTrace(); JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto"); } } } }