Usages of

org.apache.poi.xssf.streaming.SXSSFCell.getStringCellValue()
public static Boolean checkNullRow(SXSSFSheet sheet,int nRowNum,int nColNum) { SXSSFRow row = OoxmlFastUtil.getRowAnyway(sheet, nRowNum); boolean trueFlg=true; if (row != null) { for(int nCol=0;nCol<nColNum;nCol++){ SXSSFCell cell = getCellAnyway(row, nCol); if(cell.getStringCellValue()==null || cell.getStringCellValue()==""){ }else{ trueFlg=false; return trueFlg; } } } return trueFlg; }
private static void writeSegments(String fileName, SXSSFRow row, SXSSFWorkbook wb, Map<String, Map<String, Integer>> sheetCellIndex, Map<SegmentConfiguration, List<SegmentationResults>> identifiedSegments, String parentName) throws IOException { if (identifiedSegments == null) { return; } Set<SegmentConfiguration> segments = identifiedSegments.keySet(); for (SegmentConfiguration s : segments) { String segmentName = (parentName.length() > 0 ? parentName + "." : "") + s.getName(); SXSSFSheet currentSheet; boolean addRow = false; currentSheet = wb.getSheet(segmentName); if (currentSheet == null) { currentSheet = wb.getSheet("Results"); } else { addRow = true; } Map<String, Integer> cellIndex; cellIndex = sheetCellIndex.get(currentSheet.getSheetName()); List<SegmentationResults> srs = identifiedSegments.get(s); for (SegmentationResults sr : srs) { if (s.getName().equalsIgnoreCase("Not Identified")) { s.setName(""); segmentName = parentName; } //Controllo se ho durata... Map<SegmentConfiguration, List<SegmentationResults>> subSegments = sr.getSubsentencies(); if (subSegments.size() > 0) {// HO sottosegmenti if (cellIndex != null) { Integer idxSeg = cellIndex.get("SEGMENT." + segmentName); if (idxSeg != null) { String value; SXSSFCell cell = row.getCell(idxSeg); StringBuilder sb = new StringBuilder(); if (cell != null) { value = cell.getStringCellValue(); if (value != null) { sb.append(value).append("\n"); } } List<String> lines = sr.getSentencies(); lines.stream().forEach((line) -> { sb.append(line).append("\n"); }); String txt = sb.toString(); if (txt.endsWith("\n")) { txt = txt.substring(0, txt.length() - 2); } if (cell != null) { if (txt.length() > 32767) { txt = txt.substring(0, 32766); } cell.setCellValue(txt); } else { if (txt.length() > 32767) { txt = txt.substring(0, 32766); } row.createCell(idxSeg).setCellValue(txt); } } } writeSegments(fileName, row, wb, sheetCellIndex, subSegments, segmentName); } else { String txt = ""; if (cellIndex != null) { Integer idxSeg = cellIndex.get("SEGMENT." + segmentName); if (idxSeg != null) { if (addRow) { row = currentSheet.createRow(currentSheet.getLastRowNum() + 1); row.createCell(0).setCellValue(fileName); } StringBuilder sb = new StringBuilder(); List<String> lines = sr.getSentencies(); lines.stream().forEach((line) -> { sb.append(line).append("\n"); }); txt = sb.toString(); if (txt.endsWith("\n")) { txt = txt.substring(0, txt.length() - 2); } if (txt.length() > 32767) { txt = txt.substring(0, 32766); } row.createCell(idxSeg).setCellValue(txt); } } List<ClassificationPath> cps = sr.getClassificationPaths(); if (cps.size() > 0) { Sheet sheet = wb.getSheet("Bayes"); Row rx = sheet.createRow(sheet.getLastRowNum() + 1); rx.createCell(0).setCellValue(fileName); if (txt.length() > 32767) { txt = txt.substring(0, 32766); } rx.createCell(1).setCellValue(txt); String[] bayesPath1 = (String[]) cps.get(0).getPath(); double[] score1 = (double[]) cps.get(0).getScore(); String[] bayesPath2 = null; double[] score2 = null; if (cps.size() > 1) { bayesPath2 = (String[]) cps.get(1).getPath(); score2 = (double[]) cps.get(1).getScore(); } if (bayesPath1 != null) { int ClassficationPath; for (int i = 0; i < ClassificationPath.MAX_DEEP; i++) { String node = bayesPath1[i]; if (node != null) { double score = score1[i]; rx.createCell((2 * i) + 2).setCellValue(node); rx.createCell((2 * i) + 3).setCellValue(score); } } if (bayesPath2 != null) { for (int i = 0; i < ClassificationPath.MAX_DEEP; i++) { String node = bayesPath2[i]; if (node != null) { double score = score2[i]; rx.createCell((2 * i) + 14).setCellValue(node); rx.createCell((2 * i) + 15).setCellValue(score); } } } } } double duration = sr.getDurationYears(); if (duration > 0) { String key = segmentName + ".SegmentDuration"; if (cellIndex != null) { Integer idx = cellIndex.get(key); if (idx != null) { SXSSFCell dest = row.getCell(idx); if (dest == null) { row.createCell(idx).setCellValue(duration); } else { dest.setCellValue(duration); } } } } Map<CaptureConfiguration, String> captures = sr.getCaptureConfigurationResults(); if (!captures.isEmpty()) { for (CaptureConfiguration captureConfiguration : captures.keySet()) { String key = segmentName + "." + captureConfiguration.getName(); if (cellIndex != null) { Integer idx = cellIndex.get(key); if (idx != null) { SXSSFCell dest = row.getCell(idx); if (dest == null) { row.createCell(idx).setCellValue(captures.get(captureConfiguration)); } else { String val = dest.getStringCellValue(); String newOne = captures.get(captureConfiguration); if (!val.equals(newOne)) { if (!val.contains(newOne + ", ")) { val = val + ", " + newOne; } dest.setCellValue(val); } } } } } } } } } }
/** * * ������������������������������ * * @param wb * ������������������ * @param sheet * ��������� * @param rowCount * ��������� * @param valveForDL * ������������ * @param style * normal * @param styleMap * ������������style * @param tenkenrireki * ������������ * @param tenYearBefore * ������������ *@return ���rowCount * ������������������������ * */ public static Integer setDataToExcel(SXSSFWorkbook wb,SXSSFSheet sheet,int rowCount,ValveForDL valveForDL,XSSFCellStyle style,Map<String,XSSFCellStyle> styleMap,Map<String,String[]> tenkenrireki,Integer tenYearBefore) { assert sheet != null; /**���������������*/ //��������� OoxmlFastUtil.setData(sheet,rowCount,0,valveForDL.getValve().getvNo(),null);//��������� OoxmlFastUtil.setData(sheet,rowCount,1, StringUtil.nullCheck(valveForDL.getValve().getvNoSub()),null);//������ OoxmlFastUtil.setData(sheet,rowCount,2,valveForDL.getValve().getSetBasyo(),null);//������������ OoxmlFastUtil.setData(sheet,rowCount,3,valveForDL.getValve().getKeisikiRyaku(),null);//��������� OoxmlFastUtil.setData(sheet,rowCount,4,valveForDL.getValve().getAturyokuMax(),null);//������ OoxmlFastUtil.setData(sheet,rowCount,5,valveForDL.getValve().getSzHouRyaku(),null);//������������ // OoxmlFastUtil.setData(sheet,rowCount,6,valveForDL.getValve().getFutai(),null);//������ //2������ OoxmlFastUtil.setData(sheet,rowCount+1,0,valveForDL.getValve().getBenMeisyo(),null);//��������� OoxmlFastUtil.setData(sheet,rowCount+1,3,valveForDL.getValve().getSousaRyaku(),null);//������������ OoxmlFastUtil.setData(sheet,rowCount+1,4,valveForDL.getValve().getTani(),null);//������������ OoxmlFastUtil.setData(sheet,rowCount+1,5,valveForDL.getValve().getZaisituRyaku(),null);//������������ //3������ OoxmlFastUtil.setData(sheet,rowCount+2,2,valveForDL.getValve().getKeitou(),null);//������ OoxmlFastUtil.setData(sheet,rowCount+2,3,valveForDL.getValve().getClassType(),null);//��������� OoxmlFastUtil.setData(sheet,rowCount+2,4,valveForDL.getValve().getOndoMax(),null);//������(���) //4������ OoxmlFastUtil.setData(sheet,rowCount+3,3,valveForDL.getValve().getYobikeiRyaku(),null);//��������� OoxmlFastUtil.setData(sheet,rowCount+3,4,StringUtil.nullCheck(valveForDL.getValve().getRyutaiRyaku()),null);//������ // // System.out.println("result"+valveForDL.getValve().getKenanFlg().equals("1")); if(valveForDL.getValve().getKenanFlg().equals("1")){ OoxmlFastUtil.setData(sheet,rowCount,23,"���",null);//������ } int tmp=rowCount+4; int nRowStart=rowCount; //��������� setKikisysMerger(wb, sheet, nRowStart, nRowStart+3, 0, 25, styleMap); //kiki java.util.List<Kiki> kikiList=valveForDL.getKikiList(); if(kikiList.size()>0){ for(Kiki kiki:kikiList){ if(Config.KikiBunRuiA.equals(kiki.getKikiBunrui())||Config.KikiBunRuiB.equals(kiki.getKikiBunrui())||"A".equals(kiki.getKikiBunrui())||"B".equals(kiki.getKikiBunrui())){ OoxmlFastUtil.setData(sheet,rowCount,6,kiki.getKikiMei(),null);//������������ OoxmlFastUtil.setData(sheet,rowCount,7,kiki.getMakerRyaku(),null);//������������ OoxmlFastUtil.setData(sheet,rowCount,8,kiki.getKatasikiNo(),null);//������������ //������������ String[] tenkenteiRank=tenkenrireki.get(kiki.getKikiId()+""); //������������ int tenkenCol=10;//������������ ��������� if(tenkenteiRank!=null){ for(int i=tenYearBefore;i<(tenYearBefore+11);i++){ OoxmlFastUtil.setData(sheet,rowCount,tenkenCol++,tenkenteiRank[i],null);//������������ } } //������������ OoxmlFastUtil.setData(sheet,rowCount,24,tenkenteiRank[1],null);//������������ //������������--------- //������������ if(tenkenteiRank[3].contains(Config.AsbkbnA)){ OoxmlFastUtil.setData(sheet,rowCount,21,Config.AsbkbnA,null);//������������A } if(tenkenteiRank[3].contains(Config.AsbkbnN)){ OoxmlFastUtil.setData(sheet,rowCount+1,21,Config.AsbkbnN,null);//������������N } //��������������� if(tenkenteiRank[4].contains(Config.AsbkbnA)){ OoxmlFastUtil.setData(sheet,rowCount,22,Config.AsbkbnA,null);//���������������A } if(tenkenteiRank[4].contains(Config.AsbkbnN)){ OoxmlFastUtil.setData(sheet,rowCount+1,22,Config.AsbkbnN,null);//���������������N } //kiki������ // setKikiMerger(wb, sheet, rowCount, rowCount+1, 6, 6, styleMap);//������������ rowCount=rowCount+2; } } } if(rowCount<=tmp){ rowCount=tmp; } //��������������������������������� for(int i=nRowStart;i<rowCount-1;i++){ //���������������������������������������Merge boolean nullflg=true;//��������������� SXSSFRow row = OoxmlFastUtil.getRowAnyway(sheet, i); for(int cIndex=6;cIndex<25;cIndex=cIndex+1){ SXSSFCell cell=OoxmlFastUtil.getCellAnyway(row,cIndex); if(cell.getStringCellValue().length()>1){ nullflg=false; } } if(nullflg){ OoxmlFastUtil.setMerger(wb,sheet,i,i+1,6,25,null);//��������������� }else{ //kiki������ setKikiMerger(wb, sheet, i, i+1, 6, 6, styleMap);//������������ } i=i+1; } //��������������� if(rowCount-nRowStart>4){ //kiki ��������������������������������������������������������������� OoxmlFastUtil.setMerger(wb,sheet,nRowStart+4,rowCount-1,0,5,null); } OoxmlFastUtil.setTableDataCellStyle(wb,sheet,nRowStart,rowCount-1,0,25,true, styleMap); //��������������� for(int i=nRowStart;i<rowCount-1;i++){ SXSSFRow row = OoxmlFastUtil.getRowAnyway(sheet,i); row.setHeightInPoints(13); } //������ // OoxmlFastUtil.setSingleCellStyle(wb,sheet,nRowStart,nRowStart+4,11,25,CellStyle.ALIGN_CENTER,CellStyle.VERTICAL_CENTER);//������������ OoxmlFastUtil.setSingleCellStyle(wb,sheet,nRowStart+1,nRowStart+2,4,5,CellStyle.ALIGN_RIGHT,CellStyle.VERTICAL_CENTER);//������������ return rowCount; }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes