java - IndexOutOfBoundException when trying trying to get a .ods cell with jOpenDocument -
i facing little challenge coding.
file file = new file("template.ods"); sheet sheet; try { // load file sheet = spreadsheet.createfromfile(file).getsheet("certificate"); system.out.println(file); system.out.println(sheet.getcellat("a1").isempty()); sheet.setvalueat("a1", 1, 1);; system.out.println(sheet.getcellat(1, 1).gettextvalue()); sheet.getcellat(2, 2).setvalue("b2"); sheet.getcellat(3, 3).setvalue("c3"); sheet.getcellat(4, 4).setvalue("d4"); // save file , open it. file outputfile = new file("fillingtest.ods"); ooutils.open(sheet.getspreadsheet().saveas(outputfile)); } catch (exception e) { e.printstacktrace(); }
i getting know jopendocument-library. want fill existing openoffice-spreadsheet-template (template.ods) sample values. when running above code, console shows this:
template.ods
truejava.lang.indexoutofboundsexception: index: 1, size: 1 @ java.util.arraylist.rangecheck(unknown source) @ java.util.arraylist.get(unknown source) @ org.jopendocument.dom.spreadsheet.table.getrow(unknown source) @ org.jopendocument.dom.spreadsheet.table.getimmutablecellat(unknown source) @ org.jopendocument.dom.spreadsheet.table.getvalueat(unknown source) @ org.jopendocument.dom.spreadsheet.table.setvalueat(unknown source) @ jopendocument.createdocument.main(createdocument.java:48)
"template.ods" , "true" shows application retrieved file directory , "true" read cell, empty.
but don't know array throws exception , why says "unknown source".
array of rows throws exception. try adding more rows sheet.setrowcount()
before setting cell contents.
Comments
Post a Comment