We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Multiple Text Lines in a Cell

I have a project that generates a ppt with 21 columns, and a variable amount of rows. In one column, I need the possibility of entering a string with carriage return data. I know you cant do this directly, so Im trying to parse it out into multiple strings and add new paragraphs to the cells that need them. But for some reason this isnt working. The code I have compiles, but it causes weird errors, index out of bounds errors, else where, in places seemingly unrelated to what i changed.

tbl = pptPres.Slides(slide_number).Shapes.Item(1)
With tbl
....more code
.GetCell(6, n_rows).TextFrame.Paragraphs.Add(New Paragraph())
.GetCell(6, n_rows).TextFrame.Paragraphs(1).Portions.Add(New Portion())
.GetCell(6, n_rows).TextFrame.Paragraphs(0).Portions(0).Text = opr_name
.GetCell(6, n_rows).TextFrame.Paragraphs(1).Portions(0).Text = focal_name
....more code
End With

If i just do this line:
.GetCell(6, n_rows).TextFrame.Paragraphs(0).Portions(0).Text = opr_name
with everything else commented out it works fine. But adding the new paragraph, portion, and text gives me problems. Can anyone see why?



Avoid creating empty Paragraphs and Portions separately.
It’s better to clone existing ones.

Dim paras As Paragraphs = tbl.GetCell(6,n_rows).TextFrame.Paragraphs
paras.Add(New Paragraph(paras(0)))
paras(0).Portions(0).Text = opr_name
paras(1).Portions(1).Text = focal_name