Package org.jsoup.select

Examples of org.jsoup.select.Elements


      }else{
        name2Sheet.put("Spread Sheet"+i, sheet);
        name2SheetIndex.put("Spread Sheet"+i, i);
        index2SheetName.put(i, "Spread Sheet"+i);
      }
      Elements rows = sheet.select("tr");
      sheetRows.add(rows);
      List<Elements> sheetRowCell = new ArrayList<Elements>();
      for(int j=0;j<rows.size();j++){
        Element row = rows.get(j);
        Elements cells = row.select("td");
        sheetRowCell.add(cells);
      }
      sheetRowCells.add(sheetRowCell);
    }
  }
View Full Code Here


  public void resetFormulaValue(){
    for(int i=0;i<sheetRowCells.size();i++){
      //rowNum
      List<Elements> rows = sheetRowCells.get(i);
      for(int j=0;j<rows.size();j++){
        Elements row = rows.get(j);
        for(int k=0;k<row.size();k++){
          Element td = row.get(k);
          if(td.hasAttr("formula")){
            td.text("");
          }
        }
      }
View Full Code Here

    //sheetNum
    for(int i=0;i<sheetRowCells.size();i++){
      //rowNum
      List<Elements> rows = sheetRowCells.get(i);
      for(int j=0;j<rows.size();j++){
        Elements row = rows.get(j);
        //colNum
        for(int k=0;k<row.size();k++){
          Element td = row.get(k);
          if(td.hasAttr("formula")){
            evaluate(i, j, k);
          }
        }
      }
View Full Code Here

   
  }
 
  public Object evaluate(HashSet<String> es,int sheetNum,int rowNum,int colNum) throws ExcelException, RecognitionException{
    if(sheetNum>=0&&sheetNum<sheets.size()){
      Elements rows = sheetRows.get(sheetNum);
      if(rowNum>=0&&rowNum<=rows.size()){
        List<Elements> tds = sheetRowCells.get(sheetNum);
        Elements cells = tds.get(rowNum);
        if(colNum>=0&&colNum<cells.size()){
          Element cell = cells.get(colNum);
          if(cell.hasAttr("formula")){
            if(StringUtils.isBlank(cell.text())){
              String formula = cell.attr("formula");
              if(formula!=null){
                if(formula.startsWith("=")){
View Full Code Here

    }
  }
 
  public Object evaluate(int sheetNum,int rowNum,int colNum) throws ExcelException, RecognitionException{
    if(sheetNum>=0&&sheetNum<sheets.size()){
      Elements rows = sheetRows.get(sheetNum);
      if(rowNum>=0&&rowNum<=rows.size()){
        List<Elements> tds = sheetRowCells.get(sheetNum);
        Elements cells = tds.get(rowNum);
        if(colNum>=0&&colNum<cells.size()){
          Element cell = cells.get(colNum);
          if(cell.hasAttr("formula")){
            String formula = cell.attr("formula");
            if(formula!=null){
              if(formula.startsWith("=")){
                formula = formula.substring(1);
View Full Code Here

  public Object getCellValues(CellPosition position) throws ExcelException{
    if(position==null){
      throw new ExcelException("cell position is null");
    }
    if(position.sheetNum>=0&&position.sheetNum<sheets.size()){
      Elements rows = sheetRows.get(position.sheetNum);
      if(position.sRowNum>=0&&position.eRowNum<=rows.size()){
        List<Elements> tds = sheetRowCells.get(position.sheetNum);
        Elements cells = tds.get(position.sRowNum);
        if(position.sColNum>=0&&position.eColNum<cells.size()){
          List<Element> result = new ArrayList<Element>();
          for(int i=position.sRowNum;i<=position.eRowNum;i++){
            Elements currentRow = tds.get(i);
            for(int j=position.sColNum;j<=position.eColNum;j++){
              Element ele = currentRow.get(j);
              result.add(ele);
            }
          }
          return result;
        }
View Full Code Here

      testHTMLExcelBridge(content);
    }
   
    private static void testHTMLExcelBridge(String content) throws Exception, ExcelException{
      Document doc = Jsoup.parseBodyFragment(content);
      Elements sheets = doc.select("table");
      HTMLExcelBridge heb = new HTMLExcelBridge(sheets);
      heb.reEvaluateAll();
      System.out.println(sheets.toString());
    }
View Full Code Here

    return content.toString();
  }

  public void transformString(String channelString) {
    Document doc = Jsoup.parse(channelString);
    Elements tmp;
    tmp = doc.select("alias");
    if (tmp != null) {
      this.alias = (tmp.text());
    }
    tmp = doc.select("thumbImageUrl");
    if (tmp != null) {
      this.thumbImageUrl = (new Text(tmp.text()));
    }
    tmp = doc.select("title");
    if (tmp != null) {
      this.title = (new Text(tmp.text()));
    }
  }
View Full Code Here

    assumeThat(bodyHtml,notNullValue());
    Document doc = Jsoup.parseBodyFragment(bodyHtml);
    assertTrue(doc!=null);
   
   
    Elements sheets = doc.select("table");
    for(int si=0;si<sheets.size();si++){
      Element sheet = sheets.get(si);
      Elements rows = sheet.select("tbody tr");
      for(int ri=0;ri<rows.size();ri++){
        Element row = rows.get(ri);
        Elements cells = row.select("td");
        for(int ci=0;ci<cells.size();ci++){
          Element cell = cells.get(ci);
//          System.out.println(cell.toString());
          if(!org.apache.commons.lang.StringUtils.isBlank(cell.text())){
            if(cell.hasAttr("formula")){
              System.out.printf("%d %d %d (Formula[%s]) %s\n",si,ri,ci,cell.attr("formula"),cell.text());
            }else{
View Full Code Here

    try {
      TeamData team = new TeamData();
      Element teamAElem = span.previousElementSibling();
      team.setName(teamAElem.textNodes().get(0).text());
      Element table = span.parent().nextElementSibling();
      Elements rows = table.select("tbody > tr");
      team.setRiders(new ArrayList<String>());
      for (int i = 0; i < rows.size(); i++) {
        Element riderAElem = rows.get(i).select("td:eq(1) > a").get(0);
        team.getRiders().add(riderAElem.textNodes().get(0).text());
      }
      return team;
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.jsoup.select.Elements

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.