Wrap long Text to avoid overflown to next page when there is enough space

Hello,

I am trying to display a long text in a single page and export it to pdf.

The placeholder is manually placed in an excel or pdf sheet. The code searches the placeholder’s name and sets value accordingly. However, the text is overflowing to next page instead of being wrapped to next line despite there being enough space below the placeholder.

I tried using setTextWrapped but it cuts the text and shows first two or three words of entire text. I think it is only wrapping the text to one cell. When I merge the cells manually from excel and use the setTextWrapped, the texts are cut off in a weird manner.

Code snippet:

			Cell LongLoa = cells.find(“LOA_Long”, null, findOptions);  
            if (LongLoa){
				LongLoa.setValue("LOA: ABC, CDE, EFG, GHI & PHI; Class- AAA, BBB, CCC, DDD, EEE & GG; Type- ZZZ001,XXX002,YYY003,TTT004 & PPP005; Gender: F; Extra- uu123,ii123,bb12333,nn1233,gg233322 & dd12223")
				Style st = LongLoa.getStyle();
				st.setTextWrapped(true);
				LongLoa.setStyle(st);
			}

Note: In the actual code, value set to LongLoa is dynamic. Hence, the length of LongLoa will be varying.

Attached is an excel file where I am trying to put a long text in LOA_long.
resources.zip (60.8 KB)

@aasthapa,
It seems that you are using some older version of the product as I could not reproduce this issue using following sample code. Please give it a try using latest version Aspose.Cells for Java 19.12 and share the feedback.

Workbook wb = new Workbook(path + "cover_page1.xlsx");
FindOptions findOptions = new FindOptions();
Cell LongLoa = wb.getWorksheets().get(0).getCells().find("LOA_Long", null, findOptions);
if (LongLoa != null)
{
    LongLoa.setValue("LOA: ABC, CDE, EFG, GHI & PHI; Class- AAA, BBB, CCC, DDD, EEE & GG; Type- ZZZ001,XXX002,YYY003,TTT004 & PPP005; Gender: F; Extra- uu123,ii123,bb12333,nn1233,gg233322 & dd12223");

    Style st = LongLoa.getStyle();
    st.setTextWrapped(true);
    LongLoa.setStyle(st);
}
wb.save(path + "output_Java.xlsx");

Capture.PNG (6.2 KB)
output_Java.zip (6.7 KB)