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,
Hi,
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 rowCellEx cell = table.get_Item(1, rowIndex + 1);ImageEx imgEx=null;//Creating a Buffered Image object to hold the image fileBufferedImage 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);}