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

Free Support Forum - aspose.com

When inserting new rows- format of row below/above is copied

Hi there,

I’m encountering an issue when inserting a new row to the slide of the power point that was exported from the website, the format of the row below or above is copied such as background color, forecolor of text. What should I do to get rid of the format copy when inserting rows? Any help would be appreciated!

Hi Thien,

Thanks for your interest in Aspose.Slides.

The Aspose.Slides allows user to change the format related properties on each cell level. Can you please share your presentation file along with the code snippet that you are using, so that I may help you out. Your cooperation will be really helpful in resolving the issue.

We are sorry for your inconvenience,

Here is the code snippet:

//Write data into each slide
private void setupSlide(int rows, int preSlide, int nextSlide, DataTable dt)
{
this.clsPP.SetSlideTitle(“Open PM Position Status”, 20);
// Table
Aspose.Slides.Table table = clsPP.AddTable(CHART_PICTURE_X, // X Position
CHART_PICTURE_Y, // Y Position
CHART_PICTURE_WIDTH, // Width
CHART_PICTURE_HEIGHT, 14, rows + 1, 1, System.Drawing.Color.Black); // Height
// Table Header
Aspose.Slides.Cell cell = table.GetCell(0, 0);
DataRow dr;
string CellValue = string.Empty;
int count = 0;
for (int i = preSlide; i < nextSlide; i++)
{
//Add cell value
int value = 0;
CellValue = dr[“CM Days”].ToString();
//CellValue = gv.Rows[i].Cells[7].Text;
cell = table.GetCell(6, count + 1);
AddPowerPointCellData(cell, CellValue);
// clsPP.setTextBoxMargin(cell);

if (CellValue != “”)
{
value = Convert.ToInt32(CellValue);
double cellVal = Convert.ToDouble(value);
Color c = System.Drawing.ColorTranslator.FromHtml("#CCFFCC");//light green
clsPP.SetCellBackColor(cell, c);
}

}

private void AddPowerPointCellData(Cell cell, string CellValue)
{
int CellFontSize = 10;
bool bFontBold = false;

if (Util.isInteger(txtPPCellFontSize.Text))
CellFontSize = Convert.ToInt32(txtPPCellFontSize.Text);

if (cbPPCellFontBold.Checked == true)
bFontBold = true;


clsPP.SetCellText(cell,
CellValue,
bFontBold,
System.Drawing.Color.Black,
System.Drawing.Color.Transparent,
CellFontSize,
TextAlignment.Center);


}

public void SetCellText( Cell c,
string value,
bool fontBold,
Color fontColor,
Color backColor,
int fontSize,
TextAlignment alignment )

{
SetPortionText( c.TextFrame.Paragraphs[ 0 ].Portions[ 0 ],
value,
this.fontArial.FontIndex,
fontBold,
fontColor,
fontSize );
c.TextFrame.Paragraphs[ 0 ].Alignment = alignment;
SetCellBackColor( c, backColor ); // Set the background color of the cell.
}

public void SetCellBackColor( Cell c,
Color backColor )
{
if( backColor.Equals( Color.Empty ) )
{
//------------------------------------------------------------------------
// Clear the background color and set fill type to NoFill.
//------------------------------------------------------------------------

c.FillFormat.ForeColor = backColor;
c.FillFormat.Type = FillType.NoFill;
SetTextFrameBackColor( c.TextFrame, backColor );
}
else
{
//------------------------------------------------------------------------
// To set the background color of a Cell, you must set its the
// following properties:
// FillFormat.ForeColor
// FillFormat.Type
// and you must set the set the Cell’s TextFrame background color.
//------------------------------------------------------------------------

c.FillFormat.ForeColor = backColor;
c.FillFormat.Type = Aspose.Slides.FillType.Solid;
SetTextFrameBackColor( c.TextFrame, backColor );
}
}

When I attempted to insert the row, the background color of the row above or below was copied too as you can verify in the attached power point.

Thank you for your help.


Hi Thien,

I have observed the code snippet provided by you. Please understand that whenever AddRow() or AddColumn() methods are called, they actually add a clone of last row or column respectively in the table. In order to utilize the generated row or column, you have to set the formatting of each cell in that respective row or column to your desired choice.

Thanks and Regards,

Hi,

I didn’t call AddRow() or AddColumn() method anywhere. I created the table with 14 columns and 8 rows initially as below
Aspose.Slides.Table table = clsPP.AddTable(CHART_PICTURE_X, // X Position
CHART_PICTURE_Y, // Y Position
CHART_PICTURE_WIDTH, // Width
CHART_PICTURE_HEIGHT, 14, rows + 1, 1, System.Drawing.Color.Black); // Height

The above or below row was copied when inserting row happens when I did manually in the slide after I exported from the website, not from the code. Somehow I think the background color copied into the new row happened from these lines
public void SetCellBackColor( Cell c,
Color backColor )
{
if( backColor.Equals( Color.Empty ) )
{
//------------------------------------------------------------------------
// Clear the background color and set fill type to NoFill.
//------------------------------------------------------------------------

c.FillFormat.ForeColor = backColor;
c.FillFormat.Type = FillType.NoFill;
SetTextFrameBackColor( c.TextFrame, backColor );
}
else
{


c.FillFormat.ForeColor = backColor;
c.FillFormat.Type = Aspose.Slides.FillType.Solid;
SetTextFrameBackColor( c.TextFrame, backColor );
}
}
Thanks

Please disregard my issue since this is just the way it works in Powerpoint 2007 that when inserting rows, the background color of row below/above is copied too.

Thanks