您好,您这边具体是如何复现出这个问题的?我这边测试了一下并没有复现出您描述的这个情况:
代码如下:
- public class Main {
- public static List<Map> createDataSource(String preKey) {
- List<Map> dataSource = new ArrayList<>();
- for (int i = 0; i < 10; i++) {
- Map<String, String> row = new HashMap<>();
- row.put("lang_code", preKey + i);
- dataSource.add(row);
- }
- return dataSource;
- }
- public static void main(String[] args) throws IOException {
- String templatePath = "src/main/resources/template/template.xlsx";
- Workbook workbook = new Workbook();
- workbook.open(templatePath);
- List<Map> dataSource = createDataSource("测试");
- ObjectMapper objectMapper = new ObjectMapper();
- workbook.addDataSource("tableData", new JsonDataSource(objectMapper.writeValueAsString(dataSource)));
- workbook.processTemplate();
- workbook.save("src/main/resources/template/7.1.2demo.xlsx");
- }
- }
复制代码 |