You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.8 KiB
49 lines
1.8 KiB
package com.dsideal.FengHuang.Util;
|
|
|
|
import com.aspose.cells.Cells;
|
|
import com.aspose.cells.Workbook;
|
|
import com.aspose.cells.Worksheet;
|
|
import com.aspose.cells.WorksheetCollection;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.jfinal.kit.StrKit;
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
import java.io.File;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public class ExcelToHtml {
|
|
public static void main(String[] args) throws Exception {
|
|
ExcelExportUtil.getLicense();
|
|
|
|
String path = "D:\\单位项目文档\\湘潭项目相关文档\\新需求\\分拆结果";
|
|
String[] list = new File(path).list();
|
|
Map<Integer, String> _map = new HashMap<>();
|
|
int cnt = 0;
|
|
for (String s : list) {
|
|
if (!s.endsWith(".xlsx")) continue;
|
|
cnt++;
|
|
String filePath = path + "\\" + s;
|
|
Workbook workbook = new Workbook(filePath);
|
|
// 获取所有的工作簿
|
|
WorksheetCollection worksheets = workbook.getWorksheets();
|
|
// 获取第一个工作簿
|
|
Worksheet worksheet = worksheets.get(0);
|
|
// 获取所有的单元格
|
|
Cells cells = worksheet.getCells();
|
|
String value = cells.get(0, 0).getStringValue();
|
|
value = value.replace("\\t", "").replace("\\n", "");
|
|
if (StrKit.isBlank(value)) continue;
|
|
_map.put(cnt, value);
|
|
workbook.save("c:/out/" + cnt + ".html");
|
|
workbook.dispose();
|
|
}
|
|
String content="";
|
|
for (Integer key : _map.keySet()) {
|
|
String value = _map.get(key);
|
|
content += "<a href='" + key + ".html'>" + value + "</a><br>\r\n";
|
|
}
|
|
FileUtil.writeString(content,"c:/Out/index.html", "UTF-8");
|
|
}
|
|
}
|