Hi, Guillaume.

How can I do that? Is it like the "Create a spreadsheet" Tutorial,
using TableModel model = new DefaultTableModel(data, columns) ?

My goal is to load an "almost" empty spreadsheet (just column titles
and some macros), and fill it from my application.

Do you have any example?

Thanks

On 19 maio, 16:13, Guillaume Maillard <[email protected]>
wrote:
> Hi,
>
> You have to create the cells before  filling them.
>
> Regards,
> Guillaume
>
> 2011/5/19 marcio_smdo <[email protected]>
>
> > Hi there,
>
> > I'm using Eclipse Galileo, JDK 1.6.0_14, jOpenDocument-1.2.jar.
>
> > I was trying to modify an empty spreadsheet, using
> > sheet.getCellAt(int, int). I was getting
> > java.lang.IndexOutOfBoundsException all the time:
>
> > So I folowed the "Modify an existing spreadsheet" Tutorial to find out
> > if I was doing something wrong. Same result:
>
> > The code:
>
> > package testes.jopen;
>
> > import java.io.File;
> > import java.io.FileNotFoundException;
> > import java.io.IOException;
> > import java.util.Date;
>
> > import org.jopendocument.dom.OOUtils;
> > import org.jopendocument.dom.spreadsheet.Sheet;
> > import org.jopendocument.dom.spreadsheet.SpreadSheet;
>
> > public class ModifySprdst {
>
> >        public static void main(String[] args) {
> >                try {
> >                        // Load the file.
> >                         File file = new File("TableTeste.ods");
> >                         final Sheet sheet =
> > SpreadSheet.createFromFile(file).getSheet(0);
> >                         // Change date.
> >                         sheet.getCellAt("I10").setValue(new Date());
> >                         // Change strings.
> >                         sheet.setValueAt("Filling test", 1, 1);
> >                         sheet.getCellAt("B27").setValue("On site support");
> >                         // Change number.
> >                         sheet.getCellAt("F24").setValue(3);
> >                         // Save to file and open it.
> >                         File outputFile = new File("fillingTest.ods");
>
> > OOUtils.open(sheet.getSpreadSheet().saveAs(outputFile));
> >                } catch (FileNotFoundException e) {
> >                        // TODO Auto-generated catch block
> >                        e.printStackTrace();
> >                } catch (IOException e) {
> >                        // TODO Auto-generated catch block
> >                        e.printStackTrace();
> >                }
> >        }
> > }
>
> > Console output:
>
> > Exception in thread "main" java.lang.IndexOutOfBoundsException: Index:
> > 9, Size: 1
> >        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
> >        at java.util.ArrayList.get(ArrayList.java:322)
> >        at org.jopendocument.dom.spreadsheet.Table.getRow(Unknown Source)
> >        at org.jopendocument.dom.spreadsheet.Table.getCellAt(Unknown Source)
> >        at org.jopendocument.dom.spreadsheet.Table.getCellAt(Unknown Source)
> >        at org.jopendocument.dom.spreadsheet.Table.getCellAt(Unknown Source)
> >        at testes.jopen.ModifySprdst.main(ModifySprdst.java:20)
>
> > Regards.

Reply via email to