Free Support Forum - aspose.com

RowsEx.addClone and RowsEx.insertClone are broken

Perform the following on a TableEx object with 1 row:

public void addRow(TableEx table) {
int lastRowPos = table.getRows().size()-1;
RowEx lastRow = table.getRows().get(lastRowPos);
table.getRows().addClone(lastRow, false);
}

OR

public void addRow(TableEx table) {

int lastRowPos = table.getRows().size()-1;

RowEx lastRow = table.getRows().get(lastRowPos);

table.getRows().insertClone(lastRowPos+1, lastRow, true);

}

You will obtain the following exception:

java.lang.ArrayIndexOutOfBoundsException: index: 1. Wrong index of row


Why doesn’t Aspose allow us to simply add a row to the end of a table? Why doesn’t Aspose include a function to do this? It is a really simple function.

Hello Dear,

I regret to share that the mentioned support for cloning rows is at the moment unavailable due to the fact that source of the problem is still unidentified. We really fell sorry for your inconvenience but I assure you that we always try to provide best customer support by resolving their issues. An issue with ID 22338 has been created in our issue tracking system for further investigation. This thread has also been linked with the issue, so that you may be automatically notified, once the issue is resolved.

We are sorry for your inconvenience,

Good day - can you please update the status of this issue?

I am attempting to add a row to an existing table in a pptx file and receive the same ‘out of bounds’ error message as above. If it is still open, can you advise me of a way to open a presentation with a table in it, and add a new row?

Thank you.

Hi,


I have received response from our development team. Actually, we have an ongoing highest priority activity of auto porting Aspose.Slides for .NET feature to Aspose.Slides for Java and it is one huge task that will yield a more a more stable and much abundant in features version of Aspose.Slides for Java. The issue of row cloning will be automatically be resolved in the mentioned auto ported version of Aspose.Slides for Java 3.0 which is due on 23 May, 2012.

We are sorry for your inconvenience,

Hi,


I like to share that the issue shared has been resolved in Aspose.Slides for Java 6.9.0. I have attached the sample data along with generated presentation for your kind reference. I have shared the modified code sample for your convenience. Please share if I may help you further in this regard.

public static void ChangeCellImage()
{
String dataPath=“D:\Aspose Data\”;
String fileName = dataPath+ “Demo2.pptx”;
String outName = dataPath+ “Demo out.pptx”;

String[] images = new String[3];
images[0] = dataPath+ “Demo1.jpg”;
images[1] = dataPath+ “Demo2.jpg”;
images[2] = dataPath+ “Demo3.jpg”;

PresentationEx pres = new PresentationEx(fileName);

ShapeEx shape = pres.getSlides().get_Item(0).getShapes().get_Item(1);
if (shape instanceof TableEx)
{
TableEx table = (TableEx)shape;

for (int rowIndex = 0; rowIndex < 3; rowIndex++)
{
RowEx sourceRow = table.getRows().get_Item(1);
if (rowIndex > 0)
table.getRows().insertClone(rowIndex+1, sourceRow, true);//insert row
//table.getRows().addClone(sourceRow, false); //OR add row

CellEx cell = table.get_Item(1, rowIndex + 1);

ImageEx imgEx=null;
//Creating a Buffered Image object to hold the image file
BufferedImage img=null; try {
img = ImageIO.read(new File(images[rowIndex]));
} catch (IOException e) {
}
imgEx = pres.getImages().addImage(img);
cell.getFillFormat().setFillType(FillTypeEx.Picture);
cell.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillModeEx.Stretch);
cell.getFillFormat().getPictureFillFormat().getPicture().setImage(imgEx);
}
}

pres.write(outName);
}


Many Thanks,