Using aspose.cell for java java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0

Worksheet sheet1 = wb.getSheet(1);

Cells cells1=sheet1.getCells();

com.aspose.cells.ComboBox comboBox = sheet.getShapes().addComboBox(3, 5, 20,0,525,15);

cells1.getCell("A5").setValue("One");

cells1.getCell("A5").setValue("Two");

cells1.getCell("A5").setValue("Three");

cells1.getCell("A5").setValue("Four");
cells1.getCell("A5").setValue("Five");
comboBox.setLinkedCell(cell2.getName());
comboBox.setInputRange("=Sheet1!A1:Sheet1!A5");
comboBox.setDropDownLines(5);

Getting the below error

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at com.aspose.cells.Shape.a(Unknown Source)
at com.aspose.cells.ComboBox.setLinkedCell(Unknown Source)

Please let me know the soultion.

Hi,

I don’t find the issue (you have mentioned) using your code. I have used the attached version, kindly try it. Following is my sample code with the attached version and it works fine.

Sample code:
//Create a new Workbook.
Workbook wb = new Workbook();

//Get the first worksheet.
Worksheet sheet1 = wb.getSheet(0);
Cells cells1=sheet1.getCells();
com.aspose.cells.ComboBox comboBox = sheet1.getShapes().addComboBox(3, 5, 20,0,525,15);
cells1.getCell(“A1”).setValue(“One”);
cells1.getCell(“A2”).setValue(“Two”);
cells1.getCell(“A3”).setValue(“Three”);
cells1.getCell(“A4”).setValue(“Four”);
cells1.getCell(“A5”).setValue(“Five”);

comboBox.setLinkedCell(cells1.getCell(“B1”).getName());
comboBox.setInputRange("=Sheet1!A1:Sheet1!A5");
comboBox.setDropDownLines(5);

//Saves the file.
wb.save(“E:\files\outcombobox.xls”);

If you still find the issue, kindly create a simple console demo application to show the issue, we will check it soon.


Thank you.

I am not creating the new excel. Reading existing excel sheet and adding the combobox on exporting the data in the excel sheet. But when i deploy the code on other windows OS. It works only when I re-start the WebSphere server for about 10-15 min and then the below error is generating.

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
com.aspose.cells.Shape.a(Unknown Source)
com.aspose.cells.ComboBox.setLinkedCell(Unknown Source)

Even I tried to read the excel sheet that consist the form combobox. but on reading and exporting the excel the combobox are not displaying. .

Hi,

Are you using IBM's JDK1.5? There are some other users that have reported such issue with IBM's JDK1.5, one of those threads is: https://forum.aspose.com/t/68276, would you please try it to test whether it can work? If you still get such issue with this version, I am afraid the root solution should be that the bugs of IBM's JDK be fixed. Thank you.