parent
5c59e13683
commit
88db2e3373
@ -0,0 +1,44 @@
|
|||||||
|
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 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 filePath = "c:/out/map.json";
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.writeValue(new File(filePath), _map);
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue