Error when Trying to Delete Column with Merged Cells in Some Rows

Support,

Using the attached input file we’re trying to delete the last column of this table. Aspose throws an error (below) because there is a merged cell in the first row of the table. We do not want to delete the merged row, just the column which should be removed from the merged range. In PowerPoint you can delete a column and it will remove from the merged range. Is it possible to achieve this behavior using Aspose?

[Test]
public void foo46()
{
    var deck = new Presentation(@"C:\Data\temp\merge.pptx");
    var slide = deck.Slides[0];
    var table = slide.Shapes[0] as ITable;
    table.Columns.RemoveAt(2, false);

    deck.Save(@"C:\Data\temp\merged2.pptx", SaveFormat.Pptx);
}

Aspose.Slides.PptxEditException : Some of column’s cells lay outside column.
at Aspose.Slides.ColumnCollection.RemoveAt(Int32 firstColumnIndex, Boolean withAttachedRows)
at QueBIT.ReportWORQ.UnitTestsV5.Sandbox.ADW.foo46() in C:\Users\AndyWeiss\repos\ReportWORQ\QueBIT.ReportWORQ.UnitTestsV5\Sandbox\ADW.cs:line 70
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

merge.zip (25.0 KB)

Thank You,
-Andy

@weissa,
Thank you for contacting support. I am working on the issue and will get back to you soon.

1 Like

@weissa,
Thank you for your patience. To delete the last column from the table you provided, you can use the SplitByColSpan method from the ICell interface before deleting the column. I’ve edited your code example a bit and it now works as expected:

using var deck = new Presentation(@"C:\Data\temp\merge.pptx");
var slide = deck.Slides[0];
var table = slide.Shapes[0] as ITable;

table.Rows[0][0].SplitByColSpan(2); // This code line has been added.
table.Columns.RemoveAt(2, false);

deck.Save(@"C:\Data\temp\merged2.pptx", SaveFormat.Pptx);

@andrey.potapov,

Thank You for the quick response. In PowerPoint deleting a column that contains a merged row will remove the column and preserve the merged range. This technique would possibly split the merge range into two merged ranges. We would need to first scan the column for merged ranges, record the information, break the merge and delete the column, and then go back and re-merge the ranges. We’re ok with writing this algorithm, I just wanted to make sure that this is the expectation and that there isn’t already something in Aspose that will behave as I described.

Thank You,
-Andy

@weissa,
Thank you for using Aspose.Slides.