I have a dynamically built PPTX using Slides.net 18.3.
There’s only 1 Slide, which has an ITable, also built dynamically.
After being built, the ITable is too wide for the slide, so here’s what I do to “fix” the situation:
- I Clone a copy of the Original Slide (now there is the “Original” and a Clone). Both have ITables which are too wide.
- For the Original Slide - All of the ITable.Columns that are outside of the slide boundaries, I remove from the ITable starting from the far right, like this:
while (_table.width > slideWidth)
var index = _table.Columns.Count - 1;
- For each column which is removed, I save it’s respective Index to a List, as shown above.
- On the Cloned slide, I remove all of Columns EXCEPT those with the indexes from above.
The Indexes are NOT a true index due to merged cells. It isn’t reliable. If I happen to remove a Column which has merged cells somewhere within its respective Rows, the Column count could decrease by something other than 1.
There’s no way to ensure the correct Columns are removed from the Cloned ITable without peeking at the Column data, which is a poor way to work (the Column text, for example, could be the same for several Columns).
There is no such thing as a ColumnID (as there is for a SlideID). If there was, all of the above would be simple.
You cannot “Clone” Columns from one ITable to another (which is why I have to remove Columns from the Cloned ITable and not just add the Original Columns to the Clone).
Suggestions mighty appreciated. Hope this made sense.