List of usage examples for org.apache.poi.ss.usermodel Workbook getSheetAt
Sheet getSheetAt(int index);
From source file:com.github.xiilei.ecdiff.Processor.java
License:Apache License
public void diff() { try {// www .j a va 2 s . c o m logger.info("start ,src:" + job.getSrc() + ",dist:" + job.getDist()); Store store = this.getStoreFromSrc(); Workbook wb = readExcelFileByext(job.getDist()); this.font = wb.createFont(); this.font.setColor((short) 0xa); int rows_len = 0, i = 0, max_cells_len = 0; Sheet sheet = wb.getSheetAt(job.getDistSheet()); rows_len = sheet.getPhysicalNumberOfRows(); logger.info("Dist,open " + sheet.getSheetName() + " with " + rows_len + " rows"); for (i = 0; i < rows_len; i++) { Row row = sheet.getRow(i); max_cells_len = row.getPhysicalNumberOfCells(); if (!job.checkDistIndex(max_cells_len)) { logger.warn("Dist,The length of columns is too small at row " + i + ",length:" + max_cells_len); continue; } if (job.isByrow()) { cellComparer(store.get(i), row.getCell(job.getDistColumnIndex())); } else { cellComparer(store.get(getStringCellValue(row.getCell(job.getDistColumnIdIndex()))), row.getCell(job.getDistColumnIndex())); } } try (FileOutputStream out = new FileOutputStream(job.getOutFileName())) { wb.write(out); } logger.info("output file:" + job.getOutFileName()); } catch (Exception e) { logger.fatal(e.getMessage(), e); // e.printStackTrace(); } }
From source file:com.github.xiilei.ecdiff.Processor.java
License:Apache License
public Store getStoreFromSrc() throws IOException { Workbook wb = readExcelFileByext(job.getSrc()); Row row = null;/*ww w . j a v a 2s.c o m*/ int max_cells_len = 0; int rows_len = 0; Sheet sheet = wb.getSheetAt(job.getSrcSheet()); rows_len = sheet.getPhysicalNumberOfRows(); Store store = new Store(rows_len); logger.info("Src,open " + sheet.getSheetName() + " with " + rows_len + " rows"); for (int i = 0; i < rows_len; i++) { row = sheet.getRow(i); max_cells_len = row.getPhysicalNumberOfCells(); if (!job.checkSrcIndex(max_cells_len)) { logger.warn("Src,The length of columns is too small at row " + i + ",length:" + max_cells_len); continue; } if (job.isByrow()) { store.put(i, row.getCell(job.getSrcColumnIndex())); } else { store.put(getStringCellValue(row.getCell(job.getSrcColumnIdIndex())), row.getCell(job.getSrcColumnIndex())); } } return store; }
From source file:com.glaf.oa.reports.web.springmvc.OAReportController.java
License:Apache License
/** * 15???/*from w ww.jav a 2 s . co m*/ */ @ResponseBody @RequestMapping("/exportAssessQuestion") public void exportAssessQuestion(HttpServletRequest request, HttpServletResponse response) { Long resultid = RequestUtils.getLong(request, "resultid"); if (resultid != null) { // AssessresultService assessresultService = ContextFactory.getBean(AssessresultService.class); Assessresult assessresult = assessresultService.getAssessresult(resultid); // // ? // AssessquestionService assessquestionService = ContextFactory // .getBean(AssessquestionService.class); // Assessquestion assessquestion = assessquestionService // .getAssessquestion(assessresult.getQustionid()); // AssesscontentService assesscontentService = ContextFactory.getBean(AssesscontentService.class); List<AssesscontentAndScore> contentAndScoreList; // AssesssortService assesssortService = ContextFactory.getBean(AssesssortService.class); AssesssortQuery query = new AssesssortQuery(); query.setQustionid(assessresult.getQustionid()); List<Assesssort> list = assesssortService.list(query); List<AssesssortType> ty = assesssortService.getAssesssortsType("ASSESS_CLASS"); List<AssesssortType> ty1 = new ArrayList<AssesssortType>(); List<AssesssortType> sortList; AssessscoreQuery scoreQuery; int fat = 0; int fat1 = 0; int scores = 0; int scores1 = 0; boolean rst = false; for (AssesssortType a1 : ty) { fat = 0; scores = 0; rst = false; sortList = new ArrayList<AssesssortType>(); for (AssesssortType a2 : a1.getSubAssessList()) { for (Assesssort as : list) { if (as.getSortid() == a2.getId()) { rst = true; scoreQuery = new AssessscoreQuery(); scoreQuery.setResultid(resultid); scoreQuery.setSortid(as.getAssesssortid()); contentAndScoreList = assesscontentService.getAssesscontentAndScoreList(scoreQuery); for (AssesscontentAndScore aas : contentAndScoreList) { fat = (int) (fat + aas.getStandard()); scores = (int) (scores + aas.getScore()); fat1 = (int) (fat1 + aas.getStandard()); scores1 = (int) (scores1 + aas.getScore()); } a2.setAdsList(contentAndScoreList); sortList.add(a2); } } } if (rst) { a1.setSubAssessList(sortList); a1.setFat(fat + ""); a1.setScores(scores + ""); ty1.add(a1); } } map.clear(); map.put("fat1", fat1); map.put("scores1", scores1); map.put("list3", ty1); map.put("assessresult", assessresult); Workbook workBook = saveExcelWorkbook( SystemProperties.getAppPath() + "/WEB-INF/conf/templates/oa/15assessQuestion.xls", map); Sheet sheet = workBook.getSheetAt(0); convert(sheet, ty1); saveWorkbook(workBook, response, "assessQuestion" + new Date().getTime() + ".xls"); } }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
@SuppressWarnings("unused") private Sheet getSheet(Workbook p_workbook, int index) { Sheet sheet = p_workbook.getSheetAt(index); if (sheet == null) sheet = p_workbook.createSheet(); return sheet; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CommentsAnalysisReportGenerator.java
License:Apache License
private Sheet getSheet(Workbook p_workbook, int index) { Sheet sheet = p_workbook.getSheetAt(index); if (sheet == null) sheet = p_workbook.createSheet(); return sheet; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CommentsAnalysisReportGenerator.java
License:Apache License
/** * Create Report File./*from ww w . j a v a 2s . c o m*/ */ protected File getFile(String p_reportType, Job p_job, Workbook p_workBook) { String langInfo = null; // If the Workbook has only one sheet, the report name should contain language pair info, such as en_US_de_DE. if (p_workBook != null && p_workBook.getNumberOfSheets() == 1) { Sheet sheet = p_workBook.getSheetAt(0); String srcLang = null, trgLang = null; if (p_job != null) { srcLang = p_job.getSourceLocale().toString(); } if (srcLang == null) { Row languageInfoRow = sheet.getRow(LANGUAGE_INFO_ROW); if (languageInfoRow != null) { srcLang = languageInfoRow.getCell(0).getStringCellValue(); srcLang = srcLang.substring(srcLang.indexOf("[") + 1, srcLang.indexOf("]")); trgLang = languageInfoRow.getCell(1).getStringCellValue(); trgLang = trgLang.substring(trgLang.indexOf("[") + 1, trgLang.indexOf("]")); } else { Row dataRow = sheet.getRow(sheet.getLastRowNum()); if (dataRow != null) { try { long jobId = (long) dataRow.getCell(0).getNumericCellValue(); Job job = ServerProxy.getJobHandler().getJobById(jobId); srcLang = job.getSourceLocale().toString(); } catch (Exception e) { } } } } if (trgLang == null) { trgLang = sheet.getSheetName(); } if (srcLang != null && trgLang != null) { langInfo = srcLang + "_" + trgLang; } } return ReportHelper.getReportFile(p_reportType, p_job, ReportConstants.EXTENSION_XLSX, langInfo); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java
License:Apache License
/** * Create Report File./* w w w. j a v a 2 s .c o m*/ */ protected File getFile(String p_reportType, Job p_job, Workbook p_workBook) { String langInfo = null; // If the Workbook has only one sheet, the report name should contain // language pair info, such as en_US_de_DE. if (p_workBook != null && p_workBook.getNumberOfSheets() == 1) { Sheet sheet = p_workBook.getSheetAt(0); String srcLang = null, trgLang = null; if (p_job != null) { srcLang = p_job.getSourceLocale().toString(); } if (trgLang == null) { trgLang = sheet.getSheetName(); } if (srcLang != null && trgLang != null) { langInfo = srcLang + "_" + trgLang; } } return ReportHelper.getReportFile(p_reportType, p_job, ReportConstants.EXTENSION_XLSX, langInfo); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsReportGenerator.java
License:Apache License
/** * Create Report File./*ww w .j ava2 s. c om*/ */ protected File getFile(String p_reportType, Job p_job, Workbook p_workBook) { String langInfo = null; // If the Workbook has only one sheet, the report name should contain language pair info, such as en_US_de_DE. if (p_workBook != null && p_workBook.getNumberOfSheets() == 1) { Sheet sheet = p_workBook.getSheetAt(0); String srcLang = null, trgLang = null; if (p_job != null) { srcLang = p_job.getSourceLocale().toString(); } if (trgLang == null) { trgLang = sheet.getSheetName(); } if (srcLang != null && trgLang != null) { langInfo = srcLang + "_" + trgLang; } } return ReportHelper.getReportFile(p_reportType, p_job, ReportConstants.EXTENSION_XLSX, langInfo); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ScorecardReportGenerator.java
License:Apache License
/** * Create Report File.//w w w .j a va 2 s . c om */ protected File getFile(String p_reportType, Job p_job, Workbook p_workBook) { String langInfo = null; // If the Workbook has only one sheet, the report name should contain language pair info, such as en_US_de_DE. if (p_workBook != null && p_workBook.getNumberOfSheets() == 1) { Sheet sheet = p_workBook.getSheetAt(0); String srcLang = null, trgLang = null; if (p_job != null) { srcLang = p_job.getSourceLocale().toString(); } if (srcLang == null) { Row languageInfoRow = sheet.getRow(1); if (languageInfoRow != null) { srcLang = languageInfoRow.getCell(0).getStringCellValue(); srcLang = srcLang.substring(srcLang.indexOf("[") + 1, srcLang.indexOf("]")); trgLang = languageInfoRow.getCell(1).getStringCellValue(); trgLang = trgLang.substring(trgLang.indexOf("[") + 1, trgLang.indexOf("]")); } else { Row dataRow = sheet.getRow(sheet.getLastRowNum()); if (dataRow != null) { try { long jobId = (long) dataRow.getCell(0).getNumericCellValue(); Job job = ServerProxy.getJobHandler().getJobById(jobId); srcLang = job.getSourceLocale().toString(); } catch (Exception e) { } } } } if (trgLang == null) { trgLang = sheet.getSheetName(); } if (srcLang != null && trgLang != null) { langInfo = srcLang + "_" + trgLang; } } return ReportHelper.getReportFile(p_reportType, p_job, ReportConstants.EXTENSION_XLSX, langInfo); }
From source file:com.globalsight.util.ExcelUtil.java
License:Apache License
public static Sheet getSheet(Workbook workbook, int sheetNumber) { if (workbook == null || sheetNumber < 0) return null; return workbook.getSheetAt(sheetNumber); }