Table gets flipped if items exceed table (C# .NET)

Hi There,

I am using Aspose.Slides 5.0.1.0 and i am facing a wierd problem.
I have added a table to my slide(in a shape).
It works fine until numberof items are large.
as soon as items exceed to a certain limit table gets flipped vertically.
Please help.
I have attacehed the exported slides for reference.

Thanks in advance

- Neeraj

Hi Neeraj,

Thanks for your interest in Aspose.Slides.

I have tried to understand your problem statement but unfortunately I have not completely understand your problem statement. Please elaborate your problem statement in detail.

We are sorry for your inconvenience

Hi Manzoor,

Thanks for reply.

I had attached two ppt files in mu post.(if you could take a look of those files).

First ppt demonstrate normal case.when tables cells has less number of items and it renders fine in ppt slide.

in second ppt when table cells has large number of items. table is not rendering correctly.its cells are getting reverted upward(vertically).i.e., table starting position is same but it starts rendering cells upward of the slide and hence it looks bad.

is there any property or something to set so that table renders noramally enven if it has more items.

here is the code for creating this table and it cells items -

private void AddMatrix(Slide matrixSlide, List<MatrixDTO> matrixItems, int x, int y, int width, int heigth)

{

//This list is prepared to have control over the order of display boxes.

List<ItemImportanceType> importanceTypeList = new List<ItemImportanceType>() { ItemImportanceType.Critical, ItemImportanceType.Moderate, ItemImportanceType.Strong };

List<Significance> significanceList = new List<Significance>() { Significance.SignificantlyBelow, Significance.NotSignificantlyDifferent, Significance.SignificantlyAbove };

List<string> HorizontalHeaders = new List<string>() { matrixItems[0].HorizontalHeaderText, matrixItems[3].HorizontalHeaderText, matrixItems[6].HorizontalHeaderText };

List<string> verticalHeaders = new List<string>() { matrixItems[0].VerticalHeaderText, matrixItems[1].VerticalHeaderText, matrixItems[2].VerticalHeaderText };

//Adding a new table to the slide using specified table parameters

Table tableData = matrixSlide.Shapes.AddTable(x, y, width, heigth,

4, 4, 1, Color.Black);

AddMatrixHeader(tableData, HorizontalHeaders, verticalHeaders);

//Populatying cells of the table with items basedon thers impartance tpye and significance

foreach (ItemImportanceType importanceType in importanceTypeList)

{

foreach (Significance significance in significanceList)

{

FillCellColor(tableData, importanceType, significance);

foreach (MatrixDTO matrix in matrixItems)

{

if (matrix.Significance == significance && matrix.ImportanceType == importanceType)

{

if (matrix.Items != null && matrix.Items.Count > 0)

{

AddItemsToMatrix(tableData, importanceType, significance, matrix.Items);

}

}

}

}

}

}

Method for populating cells and thier formatting

private void PopulateMatrix(Table objAsposeTable, int column, int row, List<SurveyItemDTO> matrixItems)

{

Cell objAsposeTableCell = null;

objAsposeTableCell = objAsposeTable.GetCell(column, row);

//objAsposeTableCell.FillFormat.Type = FillType.Solid;

//objAsposeTableCell.FillFormat.ForeColor = Color.YellowGreen;

objAsposeTableCell.TextFrame.AnchorText = AnchorText.Top;

Paragraphs paragraphs = objAsposeTableCell.TextFrame.Paragraphs;

// content filling

paragraphs[0].Portions[0].Text = (matrixItems[0].ReportItemShortText != null) ? matrixItems[0].ReportItemShortText : "-";

paragraphs[0].Portions[0].FontHeight = 9;

paragraphs[0].Alignment = TextAlignment.Default;

paragraphs[0].HasBullet = false;

for (int index = 1; index < matrixItems.Count; index++)

{

paragraphs.Insert(index, new Paragraph(paragraphs[index - 1]));

paragraphs[index].Portions.Clear();

paragraphs[index].Portions.Add(new Portion(paragraphs[0].Portions[0]));

paragraphs[index].Portions[0].Text = (matrixItems[index].ReportItemShortText != null) ? matrixItems[index].ReportItemShortText : "-";

paragraphs[index].Portions[0].FontHeight = 9;

paragraphs[index].Alignment = TextAlignment.Default;

paragraphs[index].HasBullet = false;

}

}

Please let me know if this elaborates my question.

any feedback suggetsion would be appreciated.

Thanks,

- Neeraj

Hi Neeraj,

I have successfully generated the PPT file with following code. I have just replaced the following italic line of code with “This is test Text” and loop count is 100 because I have not your complete code. Please find generated PPT file in attachment and use the latest version of Aspose.Slides for .NET 5.3.0.

(matrixItems[index].ReportItemShortText != null) ? matrixItems[index].ReportItemShortText : “-”;

Presentation pres = new Presentation(@“d:\TableWithLessItems.ppt”);
Table tbl = (Table)pres.Slides[0].Shapes[1];

Aspose.Slides.Cell objAsposeTableCell = null;
objAsposeTableCell = tbl.GetCell(2, 0);
objAsposeTableCell.TextFrame.AnchorText = AnchorText.Top;
Paragraphs paragraphs = objAsposeTableCell.TextFrame.Paragraphs;
paragraphs[0].Portions[0].Text = “-”;
paragraphs[0].Portions[0].FontHeight = 9;
paragraphs[0].Alignment = TextAlignment.Default;
paragraphs[0].HasBullet = false;
for (int index = 1; index < 100; index++)
{
paragraphs.Insert(index, new Paragraph(paragraphs[index - 1]));
paragraphs[index].Portions.Clear();
paragraphs[index].Portions.Add(new Portion(paragraphs[0].Portions[0]));
paragraphs[index].Portions[0].Text = “This is test text”;
paragraphs[index].Portions[0].FontHeight = 9;
paragraphs[index].Alignment = TextAlignment.Default;
paragraphs[index].HasBullet = false;
}

pres.Save(“d:\AspostTable.ppt”, Aspose.Slides.Export.SaveFormat.Ppt);
this.Close();

Hi Tahir,

Thanks for your reply.

Unfortunately it's still not working.

I have used latest dll (v 5.3.1) that you have sent.but still getting the same problem.

i could notice that you have taken 100 items in a cell. i think for these many items table renders fine.problem occurs with even large number of items.probably when it exceeds to around 500.

could you please test with around 500 item in a table cell and then see if you are able to reproduce it.

Thanks,

- Neeraj

Hi Neeraj,

I am able to reproduce the same problem when I set loop count to 300. I think this is not an issue, when you add much more text in a table’s cell then the whole text is also not visible in slide show. I hope you may agree with me. Please let me know If you are not agree with me so that I can log this scenario in our issue tracking system.


@neeraj_GlobalLogic,

By using latest Aspose.Slides for .NET 20.6 API, you can achieve the same thing by using following sample code.

	public static void TestTable()
	{
		Presentation pres = new Presentation(@"d:\TableWithLessItems.ppt");
		ITable tbl = (ITable)pres.Slides[0].Shapes[1];

		var objAsposeTableCell = tbl[2, 0];
		objAsposeTableCell.TextFrame.TextFrameFormat.AnchoringType = TextAnchorType.Top;
		IParagraphCollection paragraphs = objAsposeTableCell.TextFrame.Paragraphs;
		paragraphs[0].Portions[0].Text = "-";
		paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;
		paragraphs[0].ParagraphFormat.Alignment = TextAlignment.Justify;
		for (int index = 1; index < 100; index++)
		{
			paragraphs.Insert(index, new Paragraph((Paragraph)paragraphs[index - 1]));
			paragraphs[index].Portions.Clear();
			paragraphs[index].Portions.Add(new Portion((Portion)paragraphs[0].Portions[0]));
			paragraphs[index].Portions[0].Text = "This is test text";
			paragraphs[index].Portions[0].PortionFormat.FontHeight = 9;
			paragraphs[index].ParagraphFormat.Alignment = TextAlignment.Justify;
		}

		pres.Save(@"d:\AspostTable.ppt", Aspose.Slides.Export.SaveFormat.Ppt);
	}