jxlsteam / jxls

Java library for creating Excel reports using Excel templates
http://jxls.sourceforge.net
Apache License 2.0
405 stars 92 forks source link

multi sheet template lose image #17

Open poem-love opened 4 years ago

poem-love commented 4 years ago

when use multi sheet template with image ,it will lose image on every page

SoltauFintel commented 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.

poem-love commented 4 years ago

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);
            }
        } 

test.xlsx

SoltauFintel commented 4 years ago

Because of Corona, we are currently spending significantly less time on JXLS. Therefore an answer or processing can take longer.

SoltauFintel commented 3 years ago

@leonate I have squashed the testcase (PR #18). But the issue is still unresolved. It's waiting for your fix. ;-)

mcheung610 commented 1 year ago

bump - i just ran into this exact bug

SoltauFintel commented 8 months ago

similar to #242