Bug 63494

Summary: If multiple Sheets contains RichText then on combining them into one workbook, RichText cell appears as blank from sheet 2 onward
Product: POI Reporter: Pramod <pramod.gupta>
Component: OPCAssignee: POI Developers List <dev>
Status: RESOLVED WORKSFORME    
Severity: critical    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: attached zip file contains 2 excel sheet and the generated output

Description Pramod 2019-06-10 09:27:16 UTC
Created attachment 36620 [details]
attached zip file contains 2 excel sheet and the generated output

I have multiple Excel sheet, each sheet contains few RichText Cell but when i combine all Excel sheet into a single workbook using poi-ooxml then first sheet appears correctly but in subsequent sheets we lost our RichText cell value and cell appears as blank.
Comment 1 Dominik Stadler 2019-06-20 11:18:13 UTC
Can you provide the sample-code which produces those files? Ideally as self-sufficient test-case so others can run it.

Otherwise it is hard to exactly reproduce the problem that you are facing.
Comment 2 Pramod 2019-06-25 07:06:03 UTC
This issue is now fixed for me.
i have added below lines of code when relationship type is Shared String:

sd = SstDocument.Factory.parse(p.getInputStream());
			targetsd = SstDocument.Factory.parse(partTarget.getInputStream());
			List<CTRst> ctRstArray = sd.getSst().getSiList();
			String sharedString = null;
			for (CTRst ctRst : ctRstArray) {
				if(ctRst.getRList() != null && ctRst.getRList().size()>0){
					List<CTRElt> rList = ctRst.getRList();
					targetsd.getSst().addNewSi().getRList().addAll(rList);
				}else if(ctRst.getRPhList() != null && ctRst.getRPhList().size() > 0){
					List<CTPhoneticRun> rphList = ctRst.getRPhList();
					targetsd.getSst().addNewSi().getRPhList().addAll(rphList);
				}else {
					sharedString = ctRst.getT();
					CTRst ctrst = targetsd.getSst().addNewSi();
					ctrst.setT(sharedString);
				}
			}



earlier the lines of code was:

sd = SstDocument.Factory.parse(p.getInputStream());
			targetsd = SstDocument.Factory.parse(partTarget.getInputStream());
			List<CTRst> ctRstArray = sd.getSst().getSiList();
			String sharedString = null;
			for (CTRst ctRst : ctRstArray) {
			
					sharedString = ctRst.getT();
					CTRst ctrst = targetsd.getSst().addNewSi();
					ctrst.setT(sharedString);				
			}