|
@@ -658,11 +658,12 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- /* public static void main(String[] args) throws FileNotFoundException {
|
|
|
|
|
|
+
|
|
|
|
+ /* public static void main(String[] args) throws FileNotFoundException {
|
|
|
|
|
|
String thmlUrl = "/Users/hongchuangyanfa/Desktop/1234567890.html";
|
|
String thmlUrl = "/Users/hongchuangyanfa/Desktop/1234567890.html";
|
|
|
|
|
|
- File file1 = ResourceUtil.getFile("/Users/hongchuangyanfa/Downloads/A16.xlsx");
|
|
|
|
|
|
+ File file1 = ResourceUtil.getFile("/Users/hongchuangyanfa/Downloads/D8.101.xlsx");
|
|
|
|
|
|
Workbook wb = new Workbook();
|
|
Workbook wb = new Workbook();
|
|
wb.loadFromMHtml(new FileInputStream(file1));
|
|
wb.loadFromMHtml(new FileInputStream(file1));
|
|
@@ -954,38 +955,47 @@ public class ExcelTabController extends BladeController {
|
|
inputText = inputText.substring(0, inputText.lastIndexOf("_"));
|
|
inputText = inputText.substring(0, inputText.lastIndexOf("_"));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 质检表特殊处理匹配
|
|
|
|
+
|
|
String parm = i + "," + j + "," + x1 + "," + x2 + "," + y1 + "," + y2 + ",$event";
|
|
String parm = i + "," + j + "," + x1 + "," + x2 + "," + y1 + "," + y2 + ",$event";
|
|
// 设置文本信息
|
|
// 设置文本信息
|
|
ExctabCell exctabCell = new ExctabCell();
|
|
ExctabCell exctabCell = new ExctabCell();
|
|
- if (textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0) {
|
|
|
|
-
|
|
|
|
- data.empty().append("<el-input type='text' @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + " x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' placeholder='年月日'> </el-input>");
|
|
|
|
- exctabCell.setExctabId(excelId);
|
|
|
|
- exctabCell.setTextInfo(inputText);
|
|
|
|
-
|
|
|
|
- if (inputText.contains("日期") || inputText.contains("年") || inputText.contains("月") || inputText.contains("日")){
|
|
|
|
- //日期
|
|
|
|
- exctabCell.setTextElementType(4);
|
|
|
|
- }else {
|
|
|
|
- //字符串
|
|
|
|
- exctabCell.setTextElementType(1);
|
|
|
|
|
|
+ if ((textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0)|| inputText.indexOf("日期")>=0 ) {
|
|
|
|
+ if(inputText.indexOf("日期")>=0){
|
|
|
|
+ data.empty().append("<el-date-picker type='date' format='YYYY年MM月DD日' @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + " x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' placeholder='"+inputText+"'> </el-date-picker>");
|
|
|
|
+ }else if(textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0){
|
|
|
|
+ if(inputText.indexOf("专业监理工程师:")>=0){
|
|
|
|
+ inputText="专业监理工程师_年月日";
|
|
|
|
+ }else if(inputText.indexOf("质检工程师:")>=0){
|
|
|
|
+ inputText="质检工程师_年月日";
|
|
|
|
+ }else{
|
|
|
|
+ inputText="年月日";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ data.empty().append("<el-date-picker type='date' format='YYYY年MM月DD日' @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + " x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' placeholder='年月日'> </el-date-picker>");
|
|
|
|
+ exctabCell.setTextInfo(inputText);
|
|
|
|
+ exctabCell.setExctabId(excelId);
|
|
exctabCell.setIsDeleted(0);
|
|
exctabCell.setIsDeleted(0);
|
|
exctabCell.setXys(i + "_" + j);
|
|
exctabCell.setXys(i + "_" + j);
|
|
colTitle.add(exctabCell);
|
|
colTitle.add(exctabCell);
|
|
data.attr("title", inputText);
|
|
data.attr("title", inputText);
|
|
|
|
|
|
- }else if(textInfo.indexOf("□")>=0){
|
|
|
|
|
|
+ }else if(textInfo.indexOf("□")>=0){ //下拉框
|
|
|
|
+
|
|
|
|
+ exctabCell.setTextInfo(inputText);
|
|
|
|
+ exctabCell.setExctabId(excelId);
|
|
|
|
+ exctabCell.setIsDeleted(0);
|
|
|
|
+ exctabCell.setXys(i + "_" + j);
|
|
|
|
+ colTitle.add(exctabCell);
|
|
data.attr("title", inputText);
|
|
data.attr("title", inputText);
|
|
} else {
|
|
} else {
|
|
- if (index_state) {
|
|
|
|
|
|
+ if (index_state) { // 区域内
|
|
if (rowspan >= 1) {
|
|
if (rowspan >= 1) {
|
|
data.empty().append("<el-input type='textarea' @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + " x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' :rows=" + rowspan * 2 + " placeholder=''> </el-input>");
|
|
data.empty().append("<el-input type='textarea' @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + " x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' :rows=" + rowspan * 2 + " placeholder=''> </el-input>");
|
|
} else {
|
|
} else {
|
|
data.empty().append("<el-input type='text' @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + " x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' placeholder=''> </el-input>");
|
|
data.empty().append("<el-input type='text' @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + " x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' placeholder=''> </el-input>");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
|
|
+ } else { // 区域外
|
|
if (j == 0) {
|
|
if (j == 0) {
|
|
if (colspan == maxCol && i >= 1) {
|
|
if (colspan == maxCol && i >= 1) {
|
|
if (rowspan >= 1) {
|
|
if (rowspan >= 1) {
|
|
@@ -1347,6 +1357,7 @@ public class ExcelTabController extends BladeController {
|
|
Document doc = Jsoup.parse(htmlString);
|
|
Document doc = Jsoup.parse(htmlString);
|
|
Element table = doc.select("table").first();
|
|
Element table = doc.select("table").first();
|
|
Elements trs = table.select("tr");
|
|
Elements trs = table.select("tr");
|
|
|
|
+ Elements cols = table.select("col");
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
for (String val : DataInfo.keySet()) {
|
|
for (String val : DataInfo.keySet()) {
|
|
@@ -1392,22 +1403,33 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
//https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
//https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
- // Element element = trs.get(y1).select("td").get(x1);
|
|
|
|
- String styles[] = data.attr("style").split(";");
|
|
|
|
- int Height = 0;
|
|
|
|
- for (String sty : styles) {
|
|
|
|
- if (sty.indexOf("height:") >= 0) {
|
|
|
|
- Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
|
|
|
|
|
|
+
|
|
|
|
+ BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
|
+
|
|
|
|
+ int colspan = Integer.parseInt(data.attr("colspan"));
|
|
|
|
+ int rowspan = Integer.parseInt(data.attr("rowspan"));
|
|
|
|
+ int picHeight = 0;
|
|
|
|
+ int picWidth = 0;
|
|
|
|
+ for (int i=y1;i<=(y1+rowspan);i++){ // 跨列处理
|
|
|
|
+ String dataInfo = trs.get(i).attr("height");
|
|
|
|
+ if(StringUtils.isNotEmpty(dataInfo)){
|
|
|
|
+ picHeight += Integer.parseInt(dataInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
|
- ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
|
- pic.setHeight(Height);
|
|
|
|
- System.out.println(sheet.getCellRange(y1, x1).getRowHeight());
|
|
|
|
- System.out.println(sheet.getCellRange(y1, x1).getColumnWidth());
|
|
|
|
- sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
|
|
|
+ if(colspan>=1){ //框行处理
|
|
|
|
+ for(int i=x1-1;i<x1+colspan-1;i++){
|
|
|
|
+ String dataInfo=cols.get(i).attr("width").replaceAll("px","");
|
|
|
|
+ if(StringUtils.isNotEmpty(dataInfo)){
|
|
|
|
+ picWidth += Integer.parseInt(dataInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
|
+ pic.setWidth(picWidth-10);
|
|
|
|
+ pic.setHeight(picHeight);
|
|
|
|
+ pic.setLeft(5);
|
|
} else {
|
|
} else {
|
|
final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
cellRange.setText(myData);
|
|
cellRange.setText(myData);
|