Free Support Forum - aspose.com

Reg. Deleting last column/row of table in slide

Hello Support,

I am trying to delete last unused columns from my template slide after dynamic data is filled. But it is throwing me an object ref error when I try to delete last column. I googled for the issue and found that same issue has been reported here. So I used the suggested DLL version from the post and tried to run the code. But it is still throwing error.


DLL version:- Aspose.slides 16.10

Code Snippet:-
for (int iDel = table.Columns.Count - 1; iDel > 0; iDel--)
{
if (table[iDel,1].TextFrame.Text=="Factor")
{
table.Columns.RemoveAt(iDel,false);
//table.Columns.RemoveAt(iDel,true); Tried doing both true and false
}
}

Same issue persist if I try to delete last row from table. Any help regarding this will be appreciated.

Hi Jonathan,


I have worked with sample code and everything works fine on my end. Can you please share your sample presentation so that i can investigate issue in details to help you out.

Best Regards,

Hello Adnan,

Please find attached sample slide. In slide you will find a table having multiple column headers as “Factor”. I am dynamically replacing that header with appropriate header name and related data in subsequent rows. But if there is extra unused columns remaining, I want to delete that. Similarly if there is extra rows remaining, it also needs to be deleted. The code i am using is already attached in previous post.

Hi Jonathan,


I have observed your comments. I request you to please visit this link for more details. I have shared piece of code in text file with you. Please see attachments. Please share feedback with us if there is still an issue.

Best Regards,

Can you please add code here and our company policy do not allow me to open external files.

@vdmehta36

Can you please explain your requirements that which code sample you are interested and want us to provide to you.

Table Title
ABC XYZ
Current Old Current Old
Row1 RM1 21 (100%) 0 (0%) 45 (98%) 1 (2%)
RM2 26 (96%) 1 (4%) 74 (93%) 6 (8%)
Row2 RM1 21 (100%) 0 (0%) 45 (98%) 1 (2%)
RM2 26 (96%) 1 (4%) 74 (93%) 6 (8%)

IN above structure we wanted to delete XYZ column based on some condition but we are always getting some of column’s cells lay outside ERROR. URGENT HELP IS REQUIRED. We are using ASPOSE SLIDES JAVA and this is one of the table on first slide. Likewise we have many tables on other slides, if you can help here with sample code we might use it with some workaround for other tables as well.

@vdmehta36

Please provide the source presentation file along with working sample code and desired output. Please also share the error details as well incurring on your end. We will be able to assist you further on the basis of provision of requested information.