|
@@ -10,6 +10,9 @@ import com.spire.xls.ExcelVersion;
|
|
|
import com.spire.xls.Workbook;
|
|
|
import com.spire.xls.Worksheet;
|
|
|
import com.spire.xls.core.spreadsheet.HTMLOptions;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
+import org.apache.commons.lang.ArrayUtils;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
@@ -26,13 +29,42 @@ import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
-public class ExpaileHtml {
|
|
|
+public class ExpaileHtml {
|
|
|
|
|
|
- // private final IExctabCellService exctabCellService;
|
|
|
+ // private final IExctabCellService exctabCellService;
|
|
|
|
|
|
public static void main11(String[] args) throws IOException {
|
|
|
- String dataInfo ="-";
|
|
|
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ List<String> data2 = new ArrayList<>();
|
|
|
+ data.add("1:2");
|
|
|
+
|
|
|
+
|
|
|
+ String[] intArray = new String[data.size()];
|
|
|
+ int lastMax = 0;
|
|
|
+ for (int h = 0; h < data.size() ; h++) {
|
|
|
+ int mx1 = Integer.parseInt(data.get(h).split(":")[0]);
|
|
|
+ int mx2 = Integer.parseInt(data.get(h).split(":")[1]);
|
|
|
+ if(data2.size()==0){
|
|
|
+ data2.add(data.get(0));
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if(lastMax+1==mx1){
|
|
|
+ int minVal = Integer.parseInt(data2.get(data2.size()-1).split(":")[0]);
|
|
|
+ data2.remove(data2.size()-1);
|
|
|
+ data2.add(minVal+":"+mx2);
|
|
|
+ }else{
|
|
|
+ data2.add(data.get(h));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lastMax = mx2;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println("开始");
|
|
|
+ for (String s : data2) {
|
|
|
+ System.out.println(s);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/* String thmlUrl = "/Users/hongchuangyanfa/Desktop/C10.1.xlsx" ;
|
|
@@ -53,21 +85,21 @@ public class ExpaileHtml {
|
|
|
//String url = "/Users/hongchuangyanfa/Desktop/privateUrl/1560108472350015488.html";
|
|
|
|
|
|
//指定输出文档路径
|
|
|
- // String fileName = "/Users/hongchuangyanfa/Desktop/pdf/UrlToPdf.pdf";
|
|
|
+ // String fileName = "/Users/hongchuangyanfa/Desktop/pdf/UrlToPdf.pdf";
|
|
|
|
|
|
//指定插件路径
|
|
|
- // String pluginPath = "/Users/hongchuangyanfa/tool/plugins_mac";
|
|
|
+ // String pluginPath = "/Users/hongchuangyanfa/tool/plugins_mac";
|
|
|
|
|
|
//设置插件路径
|
|
|
- // HtmlConverter.setPluginPath(pluginPath);
|
|
|
+ // HtmlConverter.setPluginPath(pluginPath);
|
|
|
//将URL转换为PDF595×842
|
|
|
- // HtmlConverter.convert(url, fileName, true, 1000000, new Size(842,595), new PdfMargins(0));
|
|
|
- // HtmlConverter.convert(url, fileName, true, 1000000, new Size(595,842), new PdfMargins(50,0,50,50 ));
|
|
|
+ // HtmlConverter.convert(url, fileName, true, 1000000, new Size(842,595), new PdfMargins(0));
|
|
|
+ // HtmlConverter.convert(url, fileName, true, 1000000, new Size(595,842), new PdfMargins(50,0,50,50 ));
|
|
|
|
|
|
|
|
|
//
|
|
|
- // HTMLOptions options = new HTMLOptions();
|
|
|
- // options.setTextMode();
|
|
|
+ // HTMLOptions options = new HTMLOptions();
|
|
|
+ // options.setTextMode();
|
|
|
/* Workbook wb = new Workbook();
|
|
|
wb.loadFromMHtml(file.getInputStream());
|
|
|
//获取工作表
|
|
@@ -87,11 +119,11 @@ public class ExpaileHtml {
|
|
|
}
|
|
|
|
|
|
// 清表上传解析方案
|
|
|
- public static void expailHtmlInfo(String thmlUrl) throws FileNotFoundException {
|
|
|
+ public static void expailHtmlInfo(String thmlUrl) throws FileNotFoundException {
|
|
|
|
|
|
// 读取
|
|
|
File file1 = ResourceUtil.getFile(thmlUrl);
|
|
|
- String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
|
|
|
/*
|
|
|
解析
|
|
@@ -102,7 +134,7 @@ public class ExpaileHtml {
|
|
|
// 样式集合
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
// 解析 style
|
|
|
- Map<String ,String > styleMap = getHtmlStyle(doc);
|
|
|
+ Map<String, String> styleMap = getHtmlStyle(doc);
|
|
|
|
|
|
//解析
|
|
|
Element table = doc.select("table").first();
|
|
@@ -110,28 +142,28 @@ public class ExpaileHtml {
|
|
|
|
|
|
// 获取总行列数
|
|
|
int maxCol = doc.select("Col").size();
|
|
|
- String [] rowData = new String[trs.size()+1];
|
|
|
+ String[] rowData = new String[trs.size() + 1];
|
|
|
|
|
|
// 行的状态
|
|
|
boolean index_state = false;
|
|
|
// 区域划分表示
|
|
|
- int xy_type = 1 ;
|
|
|
+ int xy_type = 1;
|
|
|
|
|
|
// 解析 excel元素集合
|
|
|
Set<String> colTitleSet = new HashSet<>();
|
|
|
|
|
|
// 标题集合信息
|
|
|
- List<Map<String,String>> zikey = new ArrayList<>();
|
|
|
- for(int i = 0 ;i <=trs.size()-1 ;i++) {
|
|
|
+ List<Map<String, String>> zikey = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= trs.size() - 1; i++) {
|
|
|
Element tr = trs.get(i);
|
|
|
Elements tds = tr.select("td");
|
|
|
- String xyInof = getTrInfo(tds,styleMap,index_state,xy_type,maxCol);
|
|
|
+ String xyInof = getTrInfo(tds, styleMap, index_state, xy_type, maxCol);
|
|
|
xy_type = Integer.parseInt(xyInof.split(",")[0]);
|
|
|
- tr.attr("xy_type",xyInof);
|
|
|
+ tr.attr("xy_type", xyInof);
|
|
|
index_state = Boolean.parseBoolean(xyInof.split(",")[1]);
|
|
|
- boolean isMaxCol = Integer.parseInt(xyInof.split(",")[2])==maxCol;
|
|
|
+ boolean isMaxCol = Integer.parseInt(xyInof.split(",")[2]) == maxCol;
|
|
|
// 计算单元格坐标
|
|
|
- int x= 0;
|
|
|
+ int x = 0;
|
|
|
for (int j = 0; j < tds.size(); j++) {
|
|
|
{
|
|
|
Element data = tds.get(j);
|
|
@@ -139,141 +171,141 @@ public class ExpaileHtml {
|
|
|
int rowspan = data.attr("ROWSPAN").equals("") ? 0 : Integer.parseInt(data.attr("ROWSPAN"));
|
|
|
Map<String, String> textObject = new HashMap<>();
|
|
|
// 计算
|
|
|
- int x1 =0;
|
|
|
- int x2 =0;
|
|
|
- int y1 =0;
|
|
|
- int y2 =0;
|
|
|
+ int x1 = 0;
|
|
|
+ int x2 = 0;
|
|
|
+ int y1 = 0;
|
|
|
+ int y2 = 0;
|
|
|
|
|
|
- String textInfo = data.text().trim().replaceAll(" ","");
|
|
|
+ String textInfo = data.text().trim().replaceAll(" ", "");
|
|
|
|
|
|
- y1=i+1;
|
|
|
+ y1 = i + 1;
|
|
|
//x 移位 算法
|
|
|
String getRowInfo = rowData[y1];
|
|
|
- if(getRowInfo!=null){
|
|
|
- String [] dataInfo2 = getRowInfo.split(",");
|
|
|
- if(getRowInfo.indexOf("1")>=0 && j==0){
|
|
|
- x= Integer.parseInt(dataInfo2[0].split(":")[1]);
|
|
|
- }else{
|
|
|
- for(int m =0;m<dataInfo2.length ;m++){
|
|
|
+ if (getRowInfo != null) {
|
|
|
+ String[] dataInfo2 = getRowInfo.split(",");
|
|
|
+ if (getRowInfo.indexOf("1") >= 0 && j == 0) {
|
|
|
+ x = Integer.parseInt(dataInfo2[0].split(":")[1]);
|
|
|
+ } else {
|
|
|
+ for (int m = 0; m < dataInfo2.length; m++) {
|
|
|
int mx1 = Integer.parseInt(dataInfo2[m].split(":")[0]);
|
|
|
int mx2 = Integer.parseInt(dataInfo2[m].split(":")[1]);
|
|
|
- if((mx1-x)==1 && mx1>x){
|
|
|
- x = mx2 ;
|
|
|
+ if ((mx1 - x) == 1 && mx1 > x) {
|
|
|
+ x = mx2;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// X 坐标
|
|
|
- if(colspan==0){
|
|
|
- x1 = x+1;
|
|
|
- x2 = x+1;
|
|
|
- x= x +1;
|
|
|
- }else{
|
|
|
- x1 = x+1;
|
|
|
- x2 = x+colspan;
|
|
|
- x = x+colspan;
|
|
|
+ if (colspan == 0) {
|
|
|
+ x1 = x + 1;
|
|
|
+ x2 = x + 1;
|
|
|
+ x = x + 1;
|
|
|
+ } else {
|
|
|
+ x1 = x + 1;
|
|
|
+ x2 = x + colspan;
|
|
|
+ x = x + colspan;
|
|
|
}
|
|
|
|
|
|
//x y 坐标
|
|
|
- if(rowspan==0){
|
|
|
- y2 = i+1;
|
|
|
- }else{
|
|
|
- y2 = i+rowspan;
|
|
|
- for(int k=0;k<rowspan-1;k++){
|
|
|
- String dataInfo = rowData[k+2+i];
|
|
|
- if(dataInfo==null){
|
|
|
- dataInfo = x1+":"+x2;
|
|
|
- }else{
|
|
|
- String [] dataInfo2 = dataInfo.split(",");
|
|
|
- String dataInfo3 = dataInfo2[dataInfo2.length-1];
|
|
|
+ if (rowspan == 0) {
|
|
|
+ y2 = i + 1;
|
|
|
+ } else {
|
|
|
+ y2 = i + rowspan;
|
|
|
+ for (int k = 0; k < rowspan - 1; k++) {
|
|
|
+ String dataInfo = rowData[k + 2 + i];
|
|
|
+ if (dataInfo == null) {
|
|
|
+ dataInfo = x1 + ":" + x2;
|
|
|
+ } else {
|
|
|
+ String[] dataInfo2 = dataInfo.split(",");
|
|
|
+ String dataInfo3 = dataInfo2[dataInfo2.length - 1];
|
|
|
int mx1 = Integer.parseInt(dataInfo3.split(":")[0]);
|
|
|
int mx2 = Integer.parseInt(dataInfo3.split(":")[1]);
|
|
|
- if(mx2+1==x1){
|
|
|
- dataInfo = dataInfo+","+mx1+":"+x2;
|
|
|
- }else{
|
|
|
- dataInfo = dataInfo+","+x1+":"+x2;
|
|
|
+ if (mx2 + 1 == x1) {
|
|
|
+ dataInfo = dataInfo + "," + mx1 + ":" + x2;
|
|
|
+ } else {
|
|
|
+ dataInfo = dataInfo + "," + x1 + ":" + x2;
|
|
|
}
|
|
|
}
|
|
|
- rowData[k+2+i] = dataInfo;
|
|
|
+ rowData[k + 2 + i] = dataInfo;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- // System.out.println(x1+"_"+x2+"_"+y1+"_"+y2+"_"+textInfo);
|
|
|
- // data.text(textInfo.replaceAll(" ",""));
|
|
|
- if(!textInfo.isEmpty() && !textInfo.equals("/") && !(textInfo.indexOf("年")>=0 && textInfo.indexOf("月")>=0&& textInfo.indexOf("日")>=0)&& !textInfo.equals("—") && !textInfo.equals("-") ){ // 标题区域
|
|
|
- Map<String,String> dataInfo =new HashMap<String,String>();
|
|
|
- dataInfo.put("name",textInfo);
|
|
|
- dataInfo.put("x1",x1+"");
|
|
|
- dataInfo.put("x2",x2+"");
|
|
|
- dataInfo.put("y1",y1+"");
|
|
|
- dataInfo.put("y2",y2+"");
|
|
|
- dataInfo.put("xytype",xy_type+"");
|
|
|
+ // System.out.println(x1+"_"+x2+"_"+y1+"_"+y2+"_"+textInfo);
|
|
|
+ // data.text(textInfo.replaceAll(" ",""));
|
|
|
+ if (!textInfo.isEmpty() && !textInfo.equals("/") && !(textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0) && !textInfo.equals("—") && !textInfo.equals("-")) { // 标题区域
|
|
|
+ Map<String, String> dataInfo = new HashMap<String, String>();
|
|
|
+ dataInfo.put("name", textInfo);
|
|
|
+ dataInfo.put("x1", x1 + "");
|
|
|
+ dataInfo.put("x2", x2 + "");
|
|
|
+ dataInfo.put("y1", y1 + "");
|
|
|
+ dataInfo.put("y2", y2 + "");
|
|
|
+ dataInfo.put("xytype", xy_type + "");
|
|
|
zikey.add(dataInfo);
|
|
|
- }else{ //空行
|
|
|
- List<Map<String,String>> left = new ArrayList<>();
|
|
|
- List<Map<String,String>> top = new ArrayList<>();
|
|
|
- for(int k=0 ; k< zikey.size() ;k++){
|
|
|
+ } else { //空行
|
|
|
+ List<Map<String, String>> left = new ArrayList<>();
|
|
|
+ List<Map<String, String>> top = new ArrayList<>();
|
|
|
+ for (int k = 0; k < zikey.size(); k++) {
|
|
|
String name = zikey.get(k).get("name");
|
|
|
- // String name2 = zikey.get(k).get("name").replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
- int xx1 = Integer.parseInt( zikey.get(k).get("x1"));
|
|
|
- int xx2 = Integer.parseInt( zikey.get(k).get("x2"));
|
|
|
- int yy1 = Integer.parseInt( zikey.get(k).get("y1"));
|
|
|
- int yy2 = Integer.parseInt( zikey.get(k).get("y2"));
|
|
|
- int xytype2 = Integer.parseInt( zikey.get(k).get("xytype"));
|
|
|
+ // String name2 = zikey.get(k).get("name").replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
+ int xx1 = Integer.parseInt(zikey.get(k).get("x1"));
|
|
|
+ int xx2 = Integer.parseInt(zikey.get(k).get("x2"));
|
|
|
+ int yy1 = Integer.parseInt(zikey.get(k).get("y1"));
|
|
|
+ int yy2 = Integer.parseInt(zikey.get(k).get("y2"));
|
|
|
+ int xytype2 = Integer.parseInt(zikey.get(k).get("xytype"));
|
|
|
// 左匹配
|
|
|
- if( yy1<=y1 && yy2>=y2 && xx2<x1 && xytype2==xy_type){
|
|
|
+ if (yy1 <= y1 && yy2 >= y2 && xx2 < x1 && xytype2 == xy_type) {
|
|
|
left.add(zikey.get(k));
|
|
|
}
|
|
|
//向 上 匹配
|
|
|
- if(index_state){
|
|
|
- if( xx1<=x1 && xx2 >=x2 && yy2<y1 && xytype2==xy_type){
|
|
|
+ if (index_state) {
|
|
|
+ if (xx1 <= x1 && xx2 >= x2 && yy2 < y1 && xytype2 == xy_type) {
|
|
|
top.add(zikey.get(k));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- String inputText ="";
|
|
|
+ String inputText = "";
|
|
|
// 特征值赛选 规则
|
|
|
- for(int k=0 ; k< left.size() ;k++){ // 左计算
|
|
|
- String name = left.get(k).get("name") ;//.replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
- int xx1 = Integer.parseInt( left.get(k).get("x1"));
|
|
|
- int xx2 = Integer.parseInt( left.get(k).get("x2"));
|
|
|
- int yy1 = Integer.parseInt( left.get(k).get("y1"));
|
|
|
- int yy2 = Integer.parseInt( left.get(k).get("y2"));
|
|
|
- if(index_state){ // 正向规则匹配
|
|
|
- inputText+=name+"_";
|
|
|
- }else{
|
|
|
- if(x1-xx2<=1 && y1==yy2){
|
|
|
+ for (int k = 0; k < left.size(); k++) { // 左计算
|
|
|
+ String name = left.get(k).get("name");//.replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
+ int xx1 = Integer.parseInt(left.get(k).get("x1"));
|
|
|
+ int xx2 = Integer.parseInt(left.get(k).get("x2"));
|
|
|
+ int yy1 = Integer.parseInt(left.get(k).get("y1"));
|
|
|
+ int yy2 = Integer.parseInt(left.get(k).get("y2"));
|
|
|
+ if (index_state) { // 正向规则匹配
|
|
|
+ inputText += name + "_";
|
|
|
+ } else {
|
|
|
+ if (x1 - xx2 <= 1 && y1 == yy2) {
|
|
|
inputText = name;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 特征值赛选 规则
|
|
|
- if(top!=null && top.size()>=1){
|
|
|
- for(int k=0 ; k< top.size() ;k++){ // 向上计算
|
|
|
- String name = top.get(k).get("name") ;//.replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
- int xx1 = Integer.parseInt( top.get(k).get("x1"));
|
|
|
- int xx2 = Integer.parseInt( top.get(k).get("x2"));
|
|
|
- int yy1 = Integer.parseInt( top.get(k).get("y1"));
|
|
|
- int yy2 = Integer.parseInt( top.get(k).get("y2"));
|
|
|
- inputText+=name+"_";
|
|
|
+ if (top != null && top.size() >= 1) {
|
|
|
+ for (int k = 0; k < top.size(); k++) { // 向上计算
|
|
|
+ String name = top.get(k).get("name");//.replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
+ int xx1 = Integer.parseInt(top.get(k).get("x1"));
|
|
|
+ int xx2 = Integer.parseInt(top.get(k).get("x2"));
|
|
|
+ int yy1 = Integer.parseInt(top.get(k).get("y1"));
|
|
|
+ int yy2 = Integer.parseInt(top.get(k).get("y2"));
|
|
|
+ inputText += name + "_";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(inputText!=null && inputText!="" && inputText.indexOf("_")>=0){
|
|
|
- inputText = inputText.substring(0,inputText.lastIndexOf("_"));
|
|
|
+ if (inputText != null && inputText != "" && inputText.indexOf("_") >= 0) {
|
|
|
+ inputText = inputText.substring(0, inputText.lastIndexOf("_"));
|
|
|
}
|
|
|
|
|
|
// 计算当前 输入框 标题匹配原则(左 - 上- 下)
|
|
|
- // System.out.println(x1+"_"+x2+","+y1+"_"+y2+"=="+textInfo+"=left"+left.toString() +"===top"+top.toString()+"__index_state="+index_state+"inputtext="+inputText);
|
|
|
+ // System.out.println(x1+"_"+x2+","+y1+"_"+y2+"=="+textInfo+"=left"+left.toString() +"===top"+top.toString()+"__index_state="+index_state+"inputtext="+inputText);
|
|
|
|
|
|
// 设置文本信息
|
|
|
- if(textInfo.indexOf("年")>=0 && textInfo.indexOf("月")>=0&& textInfo.indexOf("日")>=0){
|
|
|
+ if (textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0) {
|
|
|
data.empty().append("<input type='time' style='width:100%;height:100%' placeholder=''> </input>");
|
|
|
- colTitleSet.add(inputText+"签字时间");
|
|
|
- }else {
|
|
|
+ colTitleSet.add(inputText + "签字时间");
|
|
|
+ } else {
|
|
|
if (index_state) {
|
|
|
data.empty().append("<input type='text' style='width:100%;height:100%' placeholder='" + inputText + "' > </input>");
|
|
|
} else {
|
|
@@ -291,12 +323,12 @@ public class ExpaileHtml {
|
|
|
colTitleSet.add(inputText);
|
|
|
}
|
|
|
}
|
|
|
- // data.text(textInfo.replaceAll(" ",""));
|
|
|
+ // data.text(textInfo.replaceAll(" ",""));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (String keys:colTitleSet){
|
|
|
+ for (String keys : colTitleSet) {
|
|
|
System.out.println(keys.replaceAll("[^(\u4E00-\u9FA5_)]", ""));
|
|
|
}
|
|
|
|
|
@@ -306,13 +338,11 @@ public class ExpaileHtml {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//计算区域坐标
|
|
|
- public static String getTrInfo(Elements tds,Map<String ,String > styleMap,boolean index_state,Integer xy_type,int maxCol){
|
|
|
+ public static String getTrInfo(Elements tds, Map<String, String> styleMap, boolean index_state, Integer xy_type, int maxCol) {
|
|
|
|
|
|
- int x_width = 0 ;
|
|
|
- int y_width = 0 ;
|
|
|
+ int x_width = 0;
|
|
|
+ int y_width = 0;
|
|
|
int text_width = 0;
|
|
|
int width = 0;
|
|
|
|
|
@@ -323,56 +353,56 @@ public class ExpaileHtml {
|
|
|
|
|
|
int colspan = data.attr("COLSPAN").equals("") ? 1 : Integer.parseInt(data.attr("COLSPAN"));
|
|
|
String classInfo = styleMap.get(keyId);
|
|
|
- if(classInfo ==null){
|
|
|
+ if (classInfo == null) {
|
|
|
classInfo = data.attr("style");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
data.removeAttr("class");
|
|
|
- data.attr("style",styleMap.get(keyId).replaceAll("break-word","inherit"));
|
|
|
+ data.attr("style", styleMap.get(keyId).replaceAll("break-word", "inherit"));
|
|
|
}
|
|
|
|
|
|
// 计算线开始
|
|
|
- if(classInfo.indexOf("border-left-style")>=0 && classInfo.indexOf("border-top-style")>=0 && classInfo.indexOf("border-bottom-style")>=0 && classInfo.indexOf("border-right-style")>=0){
|
|
|
+ if (classInfo.indexOf("border-left-style") >= 0 && classInfo.indexOf("border-top-style") >= 0 && classInfo.indexOf("border-bottom-style") >= 0 && classInfo.indexOf("border-right-style") >= 0) {
|
|
|
x_width += colspan;
|
|
|
}
|
|
|
|
|
|
// 计算结束
|
|
|
- if(classInfo.indexOf("border-left-style")< 0 && (classInfo.indexOf("border-top-style")<0 ||classInfo.indexOf("border-top-style")>=0) && classInfo.indexOf("border-bottom-style")<0 && classInfo.indexOf("border-right-style")<0){
|
|
|
+ if (classInfo.indexOf("border-left-style") < 0 && (classInfo.indexOf("border-top-style") < 0 || classInfo.indexOf("border-top-style") >= 0) && classInfo.indexOf("border-bottom-style") < 0 && classInfo.indexOf("border-right-style") < 0) {
|
|
|
y_width += colspan;
|
|
|
}
|
|
|
|
|
|
String name = data.text().replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
- if(!name.isEmpty()){
|
|
|
+ if (!name.isEmpty()) {
|
|
|
text_width += colspan;
|
|
|
}
|
|
|
- width +=colspan;
|
|
|
+ width += colspan;
|
|
|
}
|
|
|
|
|
|
// 在区域内
|
|
|
- if(index_state){
|
|
|
+ if (index_state) {
|
|
|
//是否需要改变
|
|
|
- if(maxCol == y_width ){
|
|
|
- index_state = false ;
|
|
|
- xy_type+=1;
|
|
|
+ if (maxCol == y_width) {
|
|
|
+ index_state = false;
|
|
|
+ xy_type += 1;
|
|
|
}
|
|
|
- if(maxCol == text_width){
|
|
|
- xy_type+=1;
|
|
|
+ if (maxCol == text_width) {
|
|
|
+ xy_type += 1;
|
|
|
}
|
|
|
- }else{ // 区域外
|
|
|
- if(maxCol == x_width ){
|
|
|
- index_state = true ;
|
|
|
- xy_type+=1;
|
|
|
+ } else { // 区域外
|
|
|
+ if (maxCol == x_width) {
|
|
|
+ index_state = true;
|
|
|
+ xy_type += 1;
|
|
|
}
|
|
|
}
|
|
|
- return xy_type+","+index_state+","+width;
|
|
|
+ return xy_type + "," + index_state + "," + width;
|
|
|
}
|
|
|
|
|
|
// 获取解析样式
|
|
|
- public static Map<String ,String > getHtmlStyle(Document doc){
|
|
|
- Map<String ,String > styleMap = new HashMap<>();
|
|
|
+ public static Map<String, String> getHtmlStyle(Document doc) {
|
|
|
+ Map<String, String> styleMap = new HashMap<>();
|
|
|
Element style = doc.select("style").first();
|
|
|
Matcher cssMatcher = Pattern.compile("(\\w+)\\s*[{]([^}]+)[}]").matcher(style.html());
|
|
|
while (cssMatcher.find()) {
|
|
|
- styleMap.put(cssMatcher.group(1),cssMatcher.group(2));
|
|
|
+ styleMap.put(cssMatcher.group(1), cssMatcher.group(2));
|
|
|
}
|
|
|
return styleMap;
|
|
|
}
|