Search code examples
c#powerpointopenxmlopenxml-sdkpresentationml

OpenXML, PresentationML Table Height and Row Height on word wrap


I'm new to Open Xml, and have created a reporting application using Open Xml SDK. It populates the data in to a table, and when the table height exceeds slide border clone the slide and and populate the next set of data in new slides and so on. All works fine but when some of the rows have data that wraps to 2 lines fails to break in to new page at the exact place. Seems the reason is the Open Xml still returns the row height as same as the row height when there is single line of data. Is there anyway of resolving this.

Here is the a piece of code that does the pagination logic (CreateTextCell is a method that creates the text cell and return):

  var tbl = current.Slide.Descendants<A.Table>().First();
                var tr = new A.TableRow();
                tr.Height = 200000;
                tr.Append(CreateTextCell(product.Name));
                tr.Append(CreateTextCell(product.ProductNumber));
                tr.Append(CreateTextCell(product.Size));
                tr.Append(CreateTextCell(String.Format("{0:00}", product.ListPrice)));
                tr.Append(CreateTextCell(product.SellStartDate.ToShortDateString()));
                tbl.Append(tr);
                totalHeight += tr.Height;



                if (totalHeight > pageBorder)
                    overflow = true;

Solution

  • I had a very similar question and discovered that the height of the table is not updated when populating the table via Open XML SDK. It is only updated when the presentation is actually opened in Power Point. This obviously won't help you figure out in your code when to split the table to a new slide, but if you try this answer it might help.