Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi sheet template lose image #17

Open
poem-love opened this issue Apr 27, 2020 · 6 comments · Fixed by #18
Open

multi sheet template lose image #17

poem-love opened this issue Apr 27, 2020 · 6 comments · Fixed by #18
Assignees
Labels
bug Something isn't working
Milestone

Comments

@poem-love
Copy link

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

@poem-love poem-love added the bug Something isn't working label Apr 27, 2020
@SoltauFintel
Copy link
Member

SoltauFintel commented Apr 27, 2020

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
Copy link
Author

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 SoltauFintel self-assigned this Apr 27, 2020
SoltauFintel added a commit that referenced this issue Apr 27, 2020
@SoltauFintel SoltauFintel assigned leonate and unassigned SoltauFintel Apr 27, 2020
@SoltauFintel SoltauFintel added this to the 2.9.0 milestone Apr 27, 2020
@SoltauFintel SoltauFintel linked a pull request Apr 27, 2020 that will close this issue
@SoltauFintel
Copy link
Member

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

@SoltauFintel SoltauFintel removed this from the 2.9.0 milestone Oct 31, 2020
SoltauFintel added a commit that referenced this issue Feb 17, 2021
SoltauFintel added a commit that referenced this issue Feb 17, 2021
* don't commit build files

* #17 image and multi sheet

* #17 .gitignore
@SoltauFintel SoltauFintel reopened this Feb 17, 2021
@SoltauFintel
Copy link
Member

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

SoltauFintel added a commit that referenced this issue Feb 17, 2021
SoltauFintel added a commit that referenced this issue Feb 17, 2021
SoltauFintel added a commit that referenced this issue Feb 17, 2021
SoltauFintel added a commit that referenced this issue Feb 17, 2021
* #17 IssueG17Test -> Issue17Test

* #17 IssueG17Test -> Issue17Test

* #17 IssueG17Test -> Issue17Test
@SoltauFintel SoltauFintel added this to the 2.11.0 milestone Feb 21, 2021
@SoltauFintel SoltauFintel removed this from the 2.11.0 milestone Dec 27, 2021
@mcheung610
Copy link

bump - i just ran into this exact bug

@SoltauFintel
Copy link
Member

similar to #242

@SoltauFintel SoltauFintel added this to the 3.1.0 milestone Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants