Hi,
After we moved to the new table engine (.Net) I came across the following issue.
If we try to delete a column from a table in a powerpoint slide it throws an exception
"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index".
This error occurs for any given index. However if we add an extra coulmn using Aspose method "AddColumn" then we can delete just one column (any column) from the table. However if we add two columns using "AddColumn" then again the above exception occurs.
Try this code against a ppt file that has a table in the first slide and it will throw an exception
string templateFilePath = @"C:\test.ppt";
Presentation _presentation;
_presentation = new Presentation(templateFilePath);
Slide sd = _presentation.GetSlideByPosition(1);
for (int j = 0; j < sd.Shapes.Count; j++)
{
Shape sh = sd.Shapes[j];
if (sh.GetType() == typeof(Table))
{
Table sht = (Table)sh;
sht.DeleteColumn(0);
}
}
Now Replace the for loopabove with this and it will work
for (int j = 0; j < sd.Shapes.Count; j++)
{
Shape sh = sd.Shapes[j];
if (sh.GetType() == typeof(Table))
{
Table sht = (Table)sh;
sht.AddColumn();
sht.DeleteColumn(0);
}
}
Now replace the for loop with this and it will again throw an exception.
for (int j = 0; j < sd.Shapes.Count; j++)
{
Shape sh = sd.Shapes[j];
if (sh.GetType() == typeof(Table))
{
Table sht = (Table)sh;
sht.AddColumn();
sht.DeleteColumn(0);
sht.DeleteColumn(0);
}
}
Ronney