是否可以使用JxlsHelper设置工作表名称来填充Excel模板?
Context context = new Context();
context.putVar("data", hereIsListOfData());
InputStream templateStream = getClass().getResourceAsStream(EXCEL_TEMPLATE);
ByteArrayOutputStream output = new ByteArrayOutputStream());
JxlsHelper.getInstance().processTemplate(templateStream, output, context);
答案 0 :(得分:1)
感谢https://stackoverflow.com/a/40789235/7913021
Context context = new Context();
context.putVar("data", hereIsListOfData());
InputStream templateStream = getClass().getResourceAsStream(EXCEL_TEMPLATE);
ByteArrayOutputStream output = new ByteArrayOutputStream());
Workbook workbook = WorkbookFactory.create(templateStream);
workbook.setSheetName(0, sheetName);
PoiTransformer transformer = PoiTransformer.createTransformer(workbook);
transformer.setOutputStream(output);
JxlsHelper.getInstance().processTemplate(context, transformer);