title: How to split table to new PowerPoint slide when content flows off current slide using Open XML SDK 2.0
body: <p>I have a bunch of data that I need to export from a website to a PowerPoint presentation and have been using Open XML SDK 2.0 to perform this task.  I have a PowerPoint presentation that I am putting through Open XML SDK 2.0 Productivity Tool to generate the template code that I can use to recreate the export.  </p>
  
  <p>On one of those slides I have a table and the requirement is to add data to that table and break that table across multiple slides if the table exceeds the bottom of the slide. The approach I have taken is to determine the height of the table and if it exceeds the height of the slide, move that new content into the next slide.  I have read <a href="http://blogs.msdn.com/brian_jones/archive/2009/08/13/adding-repeating-data-to-powerpoint.aspx" rel="nofollow noreferrer">Bryan and Jones</a> blog on adding repeating data to a PowerPoint slide, but my scenario is a little different.  They use the following code:</p>
  
  <pre><code>A.Table tbl = current.Slide.Descendants&lt;A.Table&gt;().First();
  A.TableRow tr = new A.TableRow();
  tr.Height = heightInEmu;
  tr.Append(CreateDrawingCell(imageRel + imageRelId));
  tr.Append(CreateTextCell(category));
  tr.Append(CreateTextCell(subcategory));
  tr.Append(CreateTextCell(model));
  tr.Append(CreateTextCell(price.ToString()));
  tbl.Append(tr);
  imageRelId++;
  </code></pre>
  
  <p>This won't work for me since they know what height to set the table row to since it will be the height of the image, but when adding in different amounts of text I do not know the height ahead of time so I just set <code>tr.Height</code>to a default value. Here is my attempt at figuring at the table height:</p>
  
  <pre><code>   A.Table tbl = tableSlide.Slide.Descendants&lt;A.Table&gt;().First();
     A.TableRow tr = new A.TableRow();
     tr.Height = 370840L;
     tr.Append(PowerPointUtilities.CreateTextCell("This");
     tr.Append(PowerPointUtilities.CreateTextCell("is"));
     tr.Append(PowerPointUtilities.CreateTextCell("a"));
     tr.Append(PowerPointUtilities.CreateTextCell("test"));
     tr.Append(PowerPointUtilities.CreateTextCell("Test"));
     tbl.Append(tr);
     tableSlide.Slide.Save();
  
     long tableHeight = PowerPointUtilities.TableHeight(tbl);
  </code></pre>
  
  <p>Here are the helper methods:</p>
  
  <pre><code>public static A.TableCell CreateTextCell(string text)
  {
      A.TableCell tableCell = new A.TableCell(
                              new A.TextBody(new A.BodyProperties(),
                              new A.Paragraph(new A.Run(new A.Text(text)))),
                              new A.TableCellProperties());
      return tableCell;
  }
  
  public static Int64Value TableHeight(A.Table table)
  {
      long height = 0;
  
      foreach (var row in table.Descendants&lt;A.TableRow&gt;()
                               .Where(h =&gt; h.Height.HasValue))
      {
          height += row.Height.Value;
      }
  
      return height;
  }
  </code></pre>
  
  <p>This correctly adds the new table row to the existing table, but when I try and get the height of the table, it returns the original height and not the new height.  The new height meaning the default height I initially set and not the height after a large amount of text has been inserted.  It seems the height only gets readjusted when it is opened in PowerPoint.</p>
  
  <p>I have also tried accessing the height of the largest table cell in the row, but can't seem to find the right property to perform that task.</p>
  
  <p>My question is how do you determine the height of a dynamically added table row since it doesn't seem to update the height of the row until it is opened in PowerPoint?  Any other ways to determine when to split content to another slide while using Open XML SDK 2.0?  I'm open to any suggestion on a better approach someone might have taken since there isn't much documentation on this subject.</p>