Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Table


  @Test
  public void testInsertSheet() throws Exception{
    File file = new File(ResourceUtilities.getAbsolutePath(TEST_FILE));
    SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
    //index <0 , Not expected
    Table table = spDocument.insertSheet(-1);
    Assert.assertNull(table);
    //index >= sheet count
    Table tableb = spDocument.insertSheet(11);
    Assert.assertNull(tableb);
   
    //index is within the law
    Table tab = spDocument.getSheetByName("tabellDemo2");
    if(tab != null){
      for(int i=0;i<spDocument.getSheetCount();i++){
        if(tab.equals(spDocument.getSheetByIndex(i)))
          spDocument.removeSheet(i);
      }
    }
    Table tablea = spDocument.insertSheet(0);
    Column col = tablea.appendColumn();
    col.setWidth(12.99);
    Column col2 = tablea.appendColumn();
    col.setWidth(12.);
    tablea.setTableName("tabellDemo2");
    Assert.assertEquals("tabellDemo2", tablea.getTableName());
    spDocument.save(ResourceUtilities.getAbsolutePath(TEST_FILE));
   
  }
View Full Code Here


  @Test
  public void testRemoveSheet() throws Exception{
    File file = new File(ResourceUtilities.getAbsolutePath(TEST_FILE));
    SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
    //index <0 , Not expected
    Table table = spDocument.insertSheet(-1);
    Assert.assertNull(table);
    //index >= sheet count
    Table tableb = spDocument.insertSheet(11);
    Assert.assertNull(tableb);
   
    //index is within the law
    Table tab = spDocument.getSheetByName("tabellDemo2");
    if(tab != null){
      for(int i=0;i<spDocument.getSheetCount();i++){
        if(tab.equals(spDocument.getSheetByIndex(i)))
          spDocument.removeSheet(i);
      }
    }
    Table tablea = spDocument.insertSheet(0);
    Column col = tablea.appendColumn();
    col.setWidth(12.99);
    Column col2 = tablea.appendColumn();
    col.setWidth(12.);
    tablea.setTableName("tabellDemo2");
    Assert.assertEquals("tabellDemo2", tablea.getTableName());
    spDocument.removeSheet(0);
    Table tablem = spDocument.getSheetByIndex(0);
    Assert.assertNotSame(tablea, tablem);
   
    spDocument.save(ResourceUtilities.getAbsolutePath(TEST_FILE));
  }
View Full Code Here

  @Test
  public void testGetSheetByIndex2() throws Exception{
    File file = new File(ResourceUtilities.getAbsolutePath(TEST_FILE));
    SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
    //index <0 , Not expected
    Table table = spDocument.insertSheet(-1);
    Assert.assertNull(table);
    //index >= sheet count
    Table tableb = spDocument.insertSheet(11);
    Assert.assertNull(tableb);
   
    //index is within the law
    Table tab = spDocument.getSheetByName("tabellDemo1");
    if(tab != null)
      tab.remove();
   
    Table taba = spDocument.getSheetByName("Tabelle1");
    Table tablea = spDocument.insertSheet(taba,0);
    tablea.setTableName("tabellDemo1");
    Assert.assertEquals("tabellDemo1", tablea.getTableName());
    Table tablem = spDocument.getSheetByIndex(0);
    Assert.assertEquals(tablea, tablem);
   
    spDocument.save(ResourceUtilities.getAbsolutePath(TEST_FILE));
   
  }
View Full Code Here

          .setListSource("SELECT \"Publisher\", \"Identifier\" FROM \"biblio\"");
      ((ListBox) listBox).setDataField("Author");
      listBox.setAnchorType(AnchorType.AS_CHARACTER);

      // list box3
      Table table = Table.newTable(doc, 2, 2);
      table.setTableName("Table");
      Cell cell = table.getCellByPosition("B1");
      para = cell.addParagraph("Insert a list box here.");
      form.createListBox(para, listBoxRtg, "list3", false, true);

      doc.save(ResourceUtilities
          .newTestOutputFile("TestCreateListBox.odt"));
View Full Code Here

      checkbox = (CheckBox) form.createCheckBox(para, checkBoxRtg,
          "CheckBox 3", "CheckBox 3", "3");
      checkbox.setCurrentState(FormCheckboxState.CHECKED);
      checkbox.setAnchorType(AnchorType.AS_CHARACTER);

      Table table1 = Table.newTable(doc, 2, 2);
      Cell cell = table1.getCellByPosition("B1");
      para = cell.addParagraph("Insert a check box here.");
      form.createCheckBox(para, checkBoxRtg, "CheckBox 4", "CheckBox 4",
          "4");
      doc.save(ResourceUtilities
          .newTestOutputFile("TestCreateCheckbox.odt"));
View Full Code Here

    Border borderbase3 = new Border(new Color("#ff3333"), 0.0362, 0.0008, 0.0008, SupportedLinearMeasure.IN);
    Border borderbase4 = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      Cell cell1 = table.getCellByPosition("A8");
      Border border1 = cell1.getBorder(CellBordersType.BOTTOM);
      Border border11 = cell1.getBorder(CellBordersType.LEFT);
      Assert.assertEquals(borderbase1, border1);
      Assert.assertEquals(borderbase1, border11);

      Cell cell2 = table.getCellByPosition("A10");
      Border border2 = cell2.getBorder(CellBordersType.TOP);
      Assert.assertEquals(borderbase2, border2);
      Border border3 = cell2.getBorder(CellBordersType.DIAGONALBLTR);
      Assert.assertEquals(borderbase3, border3);

      Cell cell3 = table.getCellByPosition("A12");
      Border border4 = cell3.getBorder(CellBordersType.LEFT);
      Border border41 = cell3.getBorder(CellBordersType.RIGHT);
      Assert.assertEquals(borderbase4, border4);
      Assert.assertEquals(borderbase4, border41);

      Cell cell4 = table.getCellByPosition("B8");
      cell4.setBorders(CellBordersType.ALL_FOUR, borderbase1);
      Border border5 = cell4.getBorder(CellBordersType.BOTTOM);
      Border border51 = cell4.getBorder(CellBordersType.LEFT);
      Assert.assertEquals(borderbase1, border5);
      Assert.assertEquals(borderbase1, border51);

      Cell cell5 = table.getCellByPosition("B10");
      cell5.setBorders(CellBordersType.TOP, borderbase2);
      cell5.setBorders(CellBordersType.DIAGONALBLTR, borderbase3);
      Assert.assertEquals(borderbase2, cell5.getBorder(CellBordersType.TOP));
      Assert.assertEquals(borderbase3, cell5.getBorder(CellBordersType.DIAGONALBLTR));

      Cell cell6 = table.getCellByPosition("B12");
      cell6.setBorders(CellBordersType.LEFT_RIGHT, borderbase4);
      Assert.assertEquals(borderbase4, cell6.getBorder(CellBordersType.LEFT));
      Assert.assertEquals(borderbase4, cell6.getBorder(CellBordersType.RIGHT));

    } catch (Exception e) {
View Full Code Here

  public void testSetWidth() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      //setWidth
      borderbase.setWidth(0.056);
     
      Cell cell = table.getCellByPosition("A14");
      cell.setBorders(CellBordersType.LEFT, borderbase);
      cell.setBorders(CellBordersType.TOP, borderbase);

      //verification
      Border thisBorder = cell.getBorder(CellBordersType.LEFT);
View Full Code Here

  public void testSGetInnerLineWidth() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      //setWidth
      borderbase.setInnerLineWidth(0.0156);
     
      Cell cell = table.getCellByPosition("A14");
      cell.setBorders(CellBordersType.LEFT, borderbase);
      cell.setBorders(CellBordersType.TOP, borderbase);

      //verification
      Border thisBorder = cell.getBorder(CellBordersType.LEFT);
View Full Code Here

  public void testSGetDistance() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      //setWidth
    //  borderbase.setInnerLineWidth(0.0156);
      borderbase.setDistance(0.123);
     
      Cell cell = table.getCellByPosition("A14");
      cell.setBorders(CellBordersType.LEFT, borderbase);
      cell.setBorders(CellBordersType.TOP, borderbase);

      //verification
      Border thisBorder = cell.getBorder(CellBordersType.LEFT);
View Full Code Here

  public void testSGetOuterLineWidth() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
     
      System.out.println(borderbase.getOuterLineWidth());
      borderbase.setOuterLineWidth(0.125);
      System.out.println(borderbase.getOuterLineWidth());     
     
      Cell cell = table.getCellByPosition("A14");
      cell.setBorders(CellBordersType.LEFT, borderbase);
      cell.setBorders(CellBordersType.TOP, borderbase);

      //verification
      Border thisBorder = cell.getBorder(CellBordersType.LEFT);
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.table.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.