Open poem-love opened 4 years ago
Would be nice if you could post a template and sourcecode.
jx:image ( http://jxls.sourceforge.net/reference/image_command.html ) can probably be used as a workaround.
image command may be not work for image width and height had adjusted on excel like attachmennt file(not full fill in a cell).
can i use poi cloneSheet in jxls?
TEST CODE
String json = "[{\r\n" +
" \"id\": \"registered_user\",\r\n" +
" \"country_code\": \"JP\",\r\n" +
" \"app_type\": \"ANDROID\"\r\n" +
" }, {\r\n" +
" \"id\": \"registered_user1\",\r\n" +
" \"country_code \": \"KO \",\r\n" +
" \"app_type \": \"ANDROID\"\r\n" +
" }, {\r\n" +
" \"id\": \"registered_user2\",\r\n" +
" \"country_code\": \"US\",\r\n" +
" \"app_type\": \"ANDROID\"\r\n" +
" }]";
List<Map<String, Object>> datas = null;
System.out.println(json);
if(json!=null && json.length()>0) {
ObjectMapper mapper = new ObjectMapper();
if(json.startsWith("{")) {
JavaType jt = mapper.getTypeFactory().constructMapType(HashMap.class, String.class, Object.class);
Map<String, Object> aMap = mapper.readValue(json, jt);
datas = new ArrayList<Map<String, Object>>(1);
datas.add(aMap);
} else {
JavaType jt = mapper.getTypeFactory().constructCollectionType(ArrayList.class, HashMap.class);
datas = mapper.readValue(json, jt);
}
}
if(datas== null ) return;
String templatePath ="d:/test/test.xlsx";
String reportPath = "d:/test/report.xlsx";
Map<String, Object> sheets = new HashMap<String, Object>();
sheets.put("sheets", datas);
try (InputStream is = new FileInputStream(templatePath)) {
try (OutputStream os = new FileOutputStream(reportPath)) {
Context context = new Context(sheets);
JxlsHelper.getInstance().setEvaluateFormulas(true)
.processTemplate(is, os, context);
}
}
Because of Corona, we are currently spending significantly less time on JXLS. Therefore an answer or processing can take longer.
@leonate I have squashed the testcase (PR #18). But the issue is still unresolved. It's waiting for your fix. ;-)
bump - i just ran into this exact bug
similar to #242
when use multi sheet template with image ,it will lose image on every page