Package org.htmlparser.util

Examples of org.htmlparser.util.ParserUtils


            NodeList  headList = tableList.extractAllNodesThatMatch(new TagNameFilter("THEAD"), true);
            NodeList  footList = tableList.extractAllNodesThatMatch(new TagNameFilter("TFOOT"), true);
            NodeList  rowList = tableList.extractAllNodesThatMatch(new TagNameFilter("TR"), true);
           
            //Create a ParserUtils var
            ParserUtils pu = new ParserUtils();
            //Set rowCount to size of rowList
            rowCount = rowList.size();
           
           
            HSSFFont boldFont = wb.createFont();
            boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            HSSFCellStyle boldStyle = wb.createCellStyle();
            boldStyle.setFont(boldFont);
            boldStyle.setWrapText(true);
           
            //Loop through excel 'Rows'
            for ( int i = 0; i < rowList.size(); i++ ) {
                HSSFRow row;
                String htmlRow = rowList.elementAt(i).toHtml().trim();
                String[] splitHtmlRow;
                List<String> elements = new ArrayList<String>();
               
                if(i == 0 && headList.size() == 1){
                    row = sheet.createRow((short) i);
                    htmlRow = htmlRow.replace("<th></th>","<th> </th>");
                    htmlRow = htmlRow.replace("<TH></TH>","<th> </th>");
                    htmlRow = htmlRow.replace("</span>", " </span>");
                    elements.add("tr");
                    elements.add("th");
                    if (htmlRow.indexOf("<a href=") > -1) {
                      elements.add("a");
                    }
                    if (htmlRow.indexOf("<span ") > -1) {
                      elements.add("span");
                    }
                } else if(i == 1 && footList.size() == 1){
                    row = sheet.createRow((short) rowList.size() - 1);
                    htmlRow = pu.trimTags(htmlRow, new String[]{"span"},false,false);
                    htmlRow = htmlRow.replace("<td></td>","<td> </td>");
                    htmlRow = htmlRow.replace("<TD></TD>","<td> </td>");
                    elements.add("tr");
                    elements.add("td");
                  
                } else {
                   
                    if (footList.size() == 1){
                        row = sheet.createRow((short) i - 1);
                    } else {
                        row = sheet.createRow((short) i);
                    }
                   
                    htmlRow = htmlRow.replace("<td></td>","<td> </td>");
                    htmlRow = htmlRow.replace("<TD></TD>","<td> </td>");
                    htmlRow = htmlRow.replace("</span>", " </span>");
                    elements.add("tr");
                    elements.add("td");
                    if (htmlRow.indexOf("<span ") > -1) {
                      elements.add("span");
                    }
                }
               
                String[] splitElements = elements.toArray(new String[elements.size()]);
                splitHtmlRow = pu.splitTags(htmlRow, splitElements, true, false);
                colCount = splitHtmlRow.length;
               
                //Loop through excel 'Columns'
                for (int j = 0; j < splitHtmlRow.length; j++){
                    HSSFCell cell = row.createCell((short) j);
View Full Code Here

TOP

Related Classes of org.htmlparser.util.ParserUtils

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.