|
@@ -762,8 +762,8 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.fail("请上传清表!");
|
|
|
}
|
|
|
|
|
|
- File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
|
|
|
-// File file1 = ResourceUtil.getFile("D:\\develop\\1613737889349238784.html");
|
|
|
+// File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
|
|
|
+ File file1 = ResourceUtil.getFile("D:\\develop\\1633308933835718656.html");
|
|
|
FileInputStream fileInputStream = new FileInputStream(file1);
|
|
|
String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
// 解析 style
|
|
@@ -1696,8 +1696,8 @@ public class ExcelTabController extends BladeController {
|
|
|
Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
// 数据不为空 &&
|
|
|
if (StringUtils.isNotEmpty(tableNode.getHtmlUrl())) {
|
|
|
- File htmlFile = ResourceUtil.getFile(tableNode.getHtmlUrl());
|
|
|
-// File htmlFile = ResourceUtil.getFile("D:\\develop\\1613737889349238784.html");
|
|
|
+// File htmlFile = ResourceUtil.getFile(tableNode.getHtmlUrl());
|
|
|
+ File htmlFile = ResourceUtil.getFile("D:\\develop\\1633344465559093248.html");
|
|
|
if (htmlFile.exists()) {
|
|
|
String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
@@ -1720,61 +1720,67 @@ public class ExcelTabController extends BladeController {
|
|
|
if (val.indexOf("__") >= 0) {
|
|
|
String[] DataVal = val.split("__");
|
|
|
String[] xy = DataVal[1].split("_");
|
|
|
- Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
|
|
|
-
|
|
|
- if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
- int x1, y1;
|
|
|
-
|
|
|
- if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
- x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
- y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
- } else {
|
|
|
- x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
- y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
- }
|
|
|
- if (x1 == 0) {
|
|
|
- x1 = 1;
|
|
|
- }
|
|
|
- String myData = dataMap.get(val) + "";
|
|
|
- if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
- if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
- myData = myData.replace("[", "").replace("]", "");
|
|
|
- String[] dataVal = myData.split(",");
|
|
|
- String[] Start_dataStr = dataVal[0].split("T")[0].split("-");
|
|
|
- String StartDate = StringUtil.format("{}年{}月{}日", Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1);
|
|
|
-
|
|
|
- String[] end_dataStr = dataVal[1].split("T")[0].split("-");
|
|
|
- String endDate = StringUtil.format("{}年{}月{}日", end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1);
|
|
|
-
|
|
|
- if (StartDate.equals(endDate)) {
|
|
|
- myData = StartDate;
|
|
|
+ if (trs.size() <= (Integer.parseInt(xy[0])-1)) {
|
|
|
+ Element trData = trs.get(Integer.parseInt(xy[0]));
|
|
|
+ Elements tdDatas = trData.select("td");
|
|
|
+ if (tdDatas.size() <= (Integer.parseInt(xy[0]) - 1)) {
|
|
|
+ Element data = tdDatas.get(Integer.parseInt(xy[1]));
|
|
|
+
|
|
|
+ if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
+ int x1, y1;
|
|
|
+
|
|
|
+ if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
} else {
|
|
|
- myData = StartDate + "-" + endDate;
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
}
|
|
|
- } else {
|
|
|
- String[] dataStr = myData.split("T")[0].split("-");
|
|
|
- myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
- Element element = trs.get(y1).select("td").get(x1);
|
|
|
- String[] styles = element.attr("style").split(";");
|
|
|
- int Height = 0;
|
|
|
- for (String sty : styles) {
|
|
|
- if (sty.indexOf("height:") >= 0) {
|
|
|
- Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
}
|
|
|
- }
|
|
|
+ String myData = dataMap.get(val) + "";
|
|
|
+ if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
+ if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+ myData = myData.replace("[", "").replace("]", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+ String[] Start_dataStr = dataVal[0].split("T")[0].split("-");
|
|
|
+ String StartDate = StringUtil.format("{}年{}月{}日", Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1);
|
|
|
+
|
|
|
+ String[] end_dataStr = dataVal[1].split("T")[0].split("-");
|
|
|
+ String endDate = StringUtil.format("{}年{}月{}日", end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1);
|
|
|
+
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] dataStr = myData.split("T")[0].split("-");
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
+ Element element = trs.get(y1).select("td").get(x1);
|
|
|
+ String[] styles = element.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));
|
|
|
- ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
- pic.setHeight(Height);
|
|
|
- sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
+ BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
+ ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
+ pic.setHeight(Height);
|
|
|
+ sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
|
|
|
- } else {
|
|
|
- final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
- cellRange.setText(myData);
|
|
|
+ } else {
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ cellRange.setText(myData);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1791,26 +1797,33 @@ public class ExcelTabController extends BladeController {
|
|
|
String key = e.getColKey();
|
|
|
String[] keys = key.split("__");
|
|
|
String[] trtd = keys[1].split("_");
|
|
|
- Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
|
|
|
- int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
- if (x1 == 0) {
|
|
|
- x1 = 1;
|
|
|
- }
|
|
|
- int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+ if (trs.size() <= (Integer.parseInt(trtd[0])-1)) {
|
|
|
+ Element trData = trs.get(Integer.parseInt(trtd[0]));
|
|
|
+ Elements tdDatas = trData.select("td");
|
|
|
+ if (tdDatas.size() <= (Integer.parseInt(trtd[0]) - 1)) {
|
|
|
+ Element data = tdDatas.get(Integer.parseInt(trtd[1]));
|
|
|
+// Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
|
|
|
+
|
|
|
+ int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+ int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
|
|
|
- final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
|
|
|
- cellRange.setText(e.getId() + "");
|
|
|
- cellRange.getCellStyle().getFont().setColor(Color.white);
|
|
|
+ cellRange.setText(e.getId() + "");
|
|
|
+ cellRange.getCellStyle().getFont().setColor(Color.white);
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ }});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Long fileName = SnowFlakeUtil.getId();
|
|
|
String onePdfPath = file_path + "/pdf//" + fileName + ".pdf";
|
|
|
-// wb.saveToFile("d://123123.xls", ExcelVersion.Version2010);
|
|
|
+ wb.saveToFile("d://777.xls", ExcelVersion.Version2010);
|
|
|
sheet.saveToPdf(onePdfPath);
|
|
|
|
|
|
BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", onePdfPath);
|