Free Support Forum - aspose.com

Looking for help wrapping text in table cell

Aspose.slides Table. My cell text is very long. I unfortunately can not get it to wrap. Please help!

  Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation();
Slide slide = presentation.Slides[0];
ArrayList header = new ArrayList();


header.Add(new Element("h1", String.Format(CultureInfo.CurrentCulture, SiteMap.CurrentNode.Title)));

SlideGenerator.DrawList(slide, header, 700, 50, 4200, 550);

using (TimeComplianceTechnicalOrderCollection timeComplianceTechnicalOrderCollection = new TimeComplianceTechnicalOrderCollection())
{
DataTable data = new DataTable();

if (ChartType.Equals("R"))
{
data = timeComplianceTechnicalOrderCollection.GetActiveTCTOsHoldByRescind(ChartEndDate.Date);
}
else
{
data = timeComplianceTechnicalOrderCollection.GetActiveTCTOsHoldByCompliance(ChartEndDate.Date);
}

if (data != null)
{
Table table = slide.Shapes.AddTable(625, 375,2000, 550, 9, 11,1, Color.Black);

for (int i = 0; i < 11;i ++)
{
table.SetRowHeight(i, 50);
}
for (int i = 0; i < 9; i++)
{
table.SetColumnWidth(i, 500);
}

table.SetCellText(0, 1, string.Empty, 8, false);
table.SetCellText(1, 1, "TCTO Number", 8, false);

if (ChartType.Equals("R"))
{
table.SetCellText(2, 1, "TCTO TITLE SAFETY TCTOs", 8, false);
}
else
{
table.SetCellText(2, 1, "TCTO TITLES", 8, false);
}

table.SetCellText(3, 1, "Issue Date", 8, false);
table.SetCellText(4, 1, "Compliance Period", 8, false);
table.SetCellText(5,1, "Rescind Time", 8, false);
table.SetCellText(6, 1, "TCTO Type", 8, false);
table.SetCellText(7, 1, "Previous % Complete", 8, false);
table.SetCellText(8,1, "Current % Complete", 8, false);


for (int c = 0; c < 9; c++)
{
for (int r = 2; r < 11; r++)
{

if (data.Rows[r-2].Field<string>(c) != null)
{
string text = data.Rows[r].Field<string>(c);
if (text != null)
{
Cell cell = table.GetCell(c, r);

cell.TextFrame.WrapText = true;
cell.TextFrame.FitTextToShape();
table.SetCellText(c, r, text, 8, false);
}
}
}
}
}
}

// Use OutputFileName if set. If not, use OutputFileNameFormatString.
// If Title is set, use that too.
string exportFileName = string.Format("{0}.{1}", SiteMap.CurrentNode.Title, "ppt");
this.Page.Response.ContentType = "application/vnd.ms-powerpoint";
this.Page.Response.AppendHeader("content-disposition", string.Format("attachment;filename={0}", exportFileName));

System.IO.Stream output = this.Response.OutputStream;

presentation.Write(output);
this.Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

this.Page.Response.End();

Hi Tammy,

Thanks for your interest in Aspose.Slides.

Your code to wrap text is correct. Please share your complete source code for investigation purpose. See the following code snippet to wrap text of a table’s cell.

Presentation srcPres = new Presentation();

Slide srcSld = srcPres.GetSlideByPosition(1);

Table tbl = srcSld.Shapes.AddTable(300, 500, 500, 1, 1, 3);

Aspose.Slides.Cell cl = tbl.GetCell(0, 0);
cl.TextFrame.Text = "Welcome to Aspose Welcome to Aspose Welcome to Aspose Welcome to Aspose Welcome to Aspose Welcome to Aspose Welcome to Aspose Welcome to Aspose Welcome to Aspose Welcome to Aspose ";
cl.TextFrame.WrapText = true;

srcPres.Write(“d:\out.ppt”);