Free Support Forum - aspose.com

Table.DeleteColumn results in "Index was out of range" exception

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

Hello Ronney,

Thank you for the report. I have fixed the problem.
New version will be available tomorrow after testing.

Hi Alcrus,

Kudos for fixing it in super quick time. Waiting for the release.

Thanks,
Ronney

Hi Alcrus,

Can I expect to download the fix today?

Thanks,
Ronney

Sure, hot fix will be available in a couple of hours.

Hello Ronney,

You can download new hot fix here:
http://www.aspose.com/Community/Files/51/aspose.slides/category1108.aspx

Hi Alexey,

I downloaded the latest fix and tested. I still see the problem.

Can you please look into this.

Thanks,
Ronney

Hi Alexey,

Can you give me a quick update on this issue?

Thanks,
Ronney

Make sure you use latest version and don’t have old one somewhere in the cache.
If problem still there please provide presentation example to reproduce the problem.

The following code will not work on a ppt file with a table in the first slide.

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);
}
}

Thanks,
Ronney

This code works for me. Please provide ppt file where you have the problem.

It's just a normal ppt file. Anyways I have attached the file.

Thanks,
Ronney

Did you have a chance to test the file?

Thanks,
Ronney

Dear Ronney,

Thanks for reporting this bug, we will fix it as soon as possible.

Hi Shakeel,

Can you give me a date by which this bug will be resolved? We have already used your new version in our product but because of this bug we are not able to release our new version. Your answer should help me decide whther to rollback the new aspose changes and use the old aspose instead or to wait till you fix this bug.

Thanks,
Ronney

We will try to fix it and publish today.

Hello Ronney,

Please check attached hot fix. DeleteColumn should work now.