|
|
@ -1,16 +1,19 @@
|
|
|
|
package com.dsideal.FengHuang.Util;
|
|
|
|
package com.dsideal.FengHuang.Util;
|
|
|
|
|
|
|
|
|
|
|
|
import com.aspose.cells.Cells;
|
|
|
|
import cn.hutool.core.util.CharsetUtil;
|
|
|
|
import com.aspose.cells.Workbook;
|
|
|
|
import com.aspose.cells.*;
|
|
|
|
import com.aspose.cells.Worksheet;
|
|
|
|
import com.jfinal.kit.PathKit;
|
|
|
|
import com.aspose.cells.WorksheetCollection;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
|
|
import java.nio.file.StandardOpenOption;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
public class ExcelToHtml {
|
|
|
|
public class ExcelToHtml {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
@ -35,14 +38,32 @@ public class ExcelToHtml {
|
|
|
|
value = value.replace("\\t", "").replace("\\n", "");
|
|
|
|
value = value.replace("\\t", "").replace("\\n", "");
|
|
|
|
if (StrKit.isBlank(value)) continue;
|
|
|
|
if (StrKit.isBlank(value)) continue;
|
|
|
|
_map.put(cnt, value);
|
|
|
|
_map.put(cnt, value);
|
|
|
|
workbook.save("c:/out/" + cnt + ".html");
|
|
|
|
String sourcePath = "c:/Out/" + cnt + ".html";
|
|
|
|
|
|
|
|
workbook.save(sourcePath);
|
|
|
|
workbook.dispose();
|
|
|
|
workbook.dispose();
|
|
|
|
|
|
|
|
//居中
|
|
|
|
|
|
|
|
replace(sourcePath,"<body link='blue' vlink='purple' >","<body link='blue' vlink='purple' ><center>");
|
|
|
|
|
|
|
|
replace(sourcePath,"</center>","</center></body>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String content="";
|
|
|
|
String content = "";
|
|
|
|
for (Integer key : _map.keySet()) {
|
|
|
|
for (Integer key : _map.keySet()) {
|
|
|
|
String value = _map.get(key);
|
|
|
|
String value = _map.get(key);
|
|
|
|
content += "<a href='" + key + ".html'>" + value + "</a><br>\r\n";
|
|
|
|
content += "<a href='" + key + ".html'>" + value + "</a><br>\r\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FileUtil.writeString(content,"c:/Out/index.html", "UTF-8");
|
|
|
|
FileUtil.writeString(content, "c:/Out/index.html", "UTF-8");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void replace(String sourcePath,String oldStr,String newStr) {
|
|
|
|
|
|
|
|
File file = new File(sourcePath);
|
|
|
|
|
|
|
|
List<String> strings = FileUtil.readLines(file, CharsetUtil.CHARSET_UTF_8);
|
|
|
|
|
|
|
|
List<String> contonts = new ArrayList<>();
|
|
|
|
|
|
|
|
for (String s : strings) {
|
|
|
|
|
|
|
|
if (oldStr.equals(s.trim())) {
|
|
|
|
|
|
|
|
contonts.add(newStr);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
contonts.add(s);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FileUtil.writeLines(contonts, sourcePath, CharsetUtil.CHARSET_UTF_8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|