We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

DeleteColumn and AddColumn in pptx?

Hi Guys,

How do we delete/add a column in TableEx?

Hi Aneef,

I regret to inform you that there is no explicit way to add or delete the column in TableEx. However, as a work around, you may split the cells with same column ID by width and a new column will emerge. For your reference, I have shared the code snippet for adding the column by splitting cell with same column ID. Similiarly, the converse logic applies for deleting column, i.e. you may reset the contents of a particular column first and then merge each cell in the column with respective cells of next or previous column.

//Instantiate PresentationEx class that represents PPTX file

PresentationEx pres = new PresentationEx();

//Access first slide

SlideEx sld = pres.Slides[0];

//Define columns with widths and rows with heights

double[] dblCols = { 100, 50, 50 };

double[] dblRows = { 50, 30, 30, 30, 30 };

//Add table shape to slide

int idx = sld.Shapes.AddTable(100, 50, dblCols, dblRows);

TableEx tbl = (TableEx)sld.Shapes[idx];

//Set border format for each cell

foreach (RowEx row in tbl.Rows)

foreach (CellEx cell in row)

{

cell.BorderTop.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderTop.Width = 5;

cell.BorderBottom.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderBottom.Width = 5;

cell.BorderLeft.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderLeft.Width = 5;

cell.BorderRight.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderRight.Width = 5;

}

//Now we will add a colum after 1st column by spliting

int iCol = 0;

for (int iRow = 0; iRow < tbl.Rows.Count; iRow++)

{

tbl[iCol , iRow].SplitByWidth(50);

}

//Add text to the merged cell

tbl[0, 0].TextFrame.Text = "Merged Cells";

//Write PPTX to Disk

pres.Write("d:\\Aspose Data\\TableEx.pptx");

Thanks and Regards,

Hi Mudassir,

Thanks for your reply. but in the Aspose.slides.Table class we had addColumn and deleteColumn. and our current application is working using that api. we are in the process of upgrading our APIs to support pptx.

splitting an existing cell would not do the trick as the Table.addColumn did. because splitting the cell will make my existing data cell smaller and this will cause the formatting issues. same goes to the delete also if i want to delete a column, if im just merging it with the previous column what about the data in them. this might cause a major issue in existing applications.

why isnt these features available yet in the product? if anyone who are using aspose plan to upgrade to your pptx library. they are left with no proper solution ??

Dear Aneef,

Your are very right in making your point that option for adding and deleting columns in PPT table exists. However, the same features have not yet been implemented for PPTX table. That is why, I shared the work around method for adding and deleting columns with you. An issue with ID 17324 has already been created in our issue tracking system to add this feature support in Aspose.Slides for .NET. This thread has also been linked with the issue, so that you may be automatically notified, once this feature is available.

We are sorry for your inconvenience,

Hello,

Is there any workaround for deleting a column. because our product is using Aspose extensively and these two features are used mostly. at least for creating a column i can consider double the width of the existing column, and then split it by two. but deleting a column ? how can i achieve this?

Dear Aneef,

As, I have shared with you in my earlier posts that add and delete column on PPTX table is currently unavailable and there is a workaround method that can be used to achieve goal of column deletion by using MergeCells() method. Please use the code snippet given below to serve your purpose. Again, you will face the problem of cells width getting increased.

public static void addTableEx()

{

//Instantiate PresentationEx class that represents PPTX file

PresentationEx pres = new PresentationEx();

//Access first slide

SlideEx sld = pres.Slides[0];

//Define columns with widths and rows with heights

double[] dblCols = { 50,50, 50, 50 };

double[] dblRows = { 50, 30, 30, 30, 30 };

//Add table shape to slide

int idx = sld.Shapes.AddTable(100, 50, dblCols, dblRows);

TableEx tbl = (TableEx)sld.Shapes[idx];

//Set border format for each cell

foreach (RowEx row in tbl.Rows)

foreach (CellEx cell in row)

{

cell.BorderTop.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderTop.Width = 5;

cell.BorderBottom.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderBottom.Width = 5;

cell.BorderLeft.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderLeft.Width = 5;

cell.BorderRight.FillFormat.FillType = FillTypeEx.Solid;

cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;

cell.BorderRight.Width = 5;

}

//Now we will delete a colum after 1st column by spliting

int iCol = 2;

for (int iRow = 0; iRow < tbl.Rows.Count; iRow++)

{

//Resetting the cell text

tbl[iCol, iRow].TextFrame.Text = "";

tbl.MergeCells(tbl[iCol, iRow], tbl[iCol+1, iRow ], false);

}

//Write PPTX to Disk

pres.Write("d:\\Aspose Data\\TableEx.pptx");

}

Thanks and Regards,

Hi Mudassir,

I am using Aspose.Slides.dll, File Version 5.1.0.0

Just wanted to know are we still dealing with this problem of adding new column in the way mentioned above by you. And if we are, so how can we change existing table column size.


Hi Ani,


Thanks for your interest in Aspose.Slides.

I regret to share that the issue specified is still unresolved and you may still use the work around method shared. Secondly, currently there is no option available for altering the column width. I have requested our development team to share the status of the issue and will share that with you as soon as it is shared by them.

We are sorry for your inconvenience,

Thanks for your quick response Mudassir.

Hi,

Have you guys found any solutions for this (not workarounds).

Thanks,
Aneef

Hi Aneef,


I regret to share that owing to priority and enterprise support issue this issues has not been addressed so far. However, I have requested our development team lead for the updated status of the issue. I will share my findings with you as soon as the response is received.

We are sorry for your inconvenience,

Hi Aneef,


The issue specified has been scheduled for investigation during week 06 of 2012. We are hopeful to share the further information over it by then.

Many Thanks,

The issues you have found earlier (filed as SLIDESNET-17324) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)