InputStream templateInputStream = new FileInputStream("template.xlsx"); ExcelTemplate template = new ExcelTemplate(templateInputStream); template.setVariable("name", "John Doe"); template.setVariable("age", 30); template.setVariable("email", "john.doe@example.com"); OutputStream outputStream = new FileOutputStream("output.xlsx"); template.process(outputStream); outputStream.close(); templateInputStream.close(); InputStream templateInputStream = new FileInputStream("template.xlsx"); ExcelTemplate template = new ExcelTemplate(templateInputStream); List<Map<String, Object>> data = template.parse(); for (Map<String, Object> row : data) { String name = (String) row.get("name"); int age = (int) row.get("age"); String email = (String) row.get("email"); // ... } templateInputStream.close(); InputStream templateInputStream = new FileInputStream("template.xlsx"); ExcelTemplate template = new ExcelTemplate(templateInputStream); ValidationResult result = template.validate(); if (result.isValid()) { } else { List<String> errorMessages = result.getErrorMessages(); for (String errorMessage : errorMessages) { // ... } } templateInputStream.close();


上一篇:
下一篇:
切换中文