Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Table


  public void testSGetLinearMeasure() {
    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");
     
      borderbase.setLinearMeasure(StyleTypeDefinitions.SupportedLinearMeasure.CM);
     
      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


      form.createButton(doc, btnRtg, "Button2", "Push Button 2");

      Paragraph para = doc.addParagraph("Insert a button here.");
      form.createButton(para, btnRtg, "Button3", "Push Button 3");

      Table table1 = Table.newTable(doc, 2, 2);
      Cell cell = table1.getCellByPosition("A1");
      para = cell.addParagraph("Insert a button here:");
      form.createButton(para, btnRtg, "Button4", "Push Button 4");

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

      String[] columnlabels = new String[columncount];
      for (int i = 0; i < columncount; i++) {
        columnlabels[i] = "ColumnHeader" + i;
      }
      Table table = Table.newTable(sourcedoc, rowlabels, columnlabels, data);
      table.setTableName(tablename);
     
     
      String tablename2 = "Table2";
      int rowcount2 = 10, columncount2 = 4;
      double[][] data2 = new double[rowcount2][columncount2];
      for (int i = 0; i < rowcount2; i++) {
        for (int j = 0; j < columncount2; j++) {
          data2[i][j] = Math.random();
        }
      }

      String[] rowlabels2 = new String[rowcount2];
      for (int i = 0; i < rowcount2; i++) {
        rowlabels2[i] = "RowHeader" + i;
      }

      String[] columnlabels2 = new String[columncount2];
      for (int i = 0; i < columncount2; i++) {
        columnlabels2[i] = "ColumnHeader" + i;
      }

      Table table2 = Table.newTable(sourcedoc, rowlabels2, columnlabels2, data2);
      table2.setTableName(tablename2);
     
      String tablename3 = "Table3";
      int rownumber3 = 5;
      int clmnumber3 = 3;

      Table table1 = Table.newTable(sourcedoc, rownumber3, clmnumber3);
      table1.setTableName(tablename3);
      sourcedoc.save(ResourceUtilities.newTestOutputFile("TestTableSelectionSource.odt"));
    } catch (Exception e) {
      Logger.getLogger(TableSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
View Full Code Here

    search = new TextNavigation("SIMPLE", doc);
   
    while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        TableSelection nextTableSelection=new TableSelection(item);
        Table table=sourcedoc.getTableByName("Table1");
        Cell cell = table.getCellByPosition(0, 0);
        cell.setStringValue("SIMPLE");
        Table newtable = nextTableSelection.replaceWithTable(table);
        Assert.assertNotNull(newtable);
        Assert.assertEquals(1, newtable.getHeaderColumnCount());
        Assert.assertEquals(1, newtable.getHeaderRowCount());
        Assert.assertEquals(7 + 1, newtable.getRowCount());
        Assert.assertEquals(5 + 1, newtable.getColumnCount());
        cell = newtable.getCellByPosition(1, 1);
        Assert.assertEquals("string", cell.getValueType());
    }
 
   
    //2 Task1, #1 at the start of original Paragraph, #2 replace original Paragraph 
        search = new TextNavigation("Task1", doc);
        
        while (search.hasNext()) {
            TextSelection item = (TextSelection) search.nextSelection();
            TableSelection nextTableSelection=new TableSelection(item);
            Table table=sourcedoc.getTableByName("Table2");
            Table newtable = nextTableSelection.replaceWithTable(table);
            Cell cell = newtable.getCellByPosition(0, 0);
            cell.setStringValue("From Source Table2");
            Assert.assertNotNull(newtable);
            Assert.assertEquals(1, newtable.getHeaderColumnCount());
            Assert.assertEquals(1, newtable.getHeaderRowCount());
            Assert.assertEquals(10 + 1, newtable.getRowCount());
            Assert.assertEquals(4 + 1, newtable.getColumnCount());
           
            cell = newtable.getCellByPosition(1, 1);
            Assert.assertEquals("float", cell.getValueType());
        }   
        //1 RESS%>, #1 at the end of original Paragraph,
        search = new TextNavigation("RESS%>", doc);

        while (search.hasNext()) {
            TextSelection item = (TextSelection) search.nextSelection();
            TableSelection nextTableSelection=new TableSelection(item);
            Table table=sourcedoc.getTableByName("Table3");
            Table newtable = nextTableSelection.replaceWithTable(table);
            Cell cell = newtable.getCellByPosition(0, 0);
            cell.setStringValue("From Source Table3");
            Assert.assertNotNull(newtable);
            Assert.assertEquals(5, newtable.getRowCount());
            Assert.assertEquals(3, newtable.getColumnCount());

        }       
       
    try {
      doc.save(ResourceUtilities.newTestOutputFile("TestTableSelectionResult.odt"));
View Full Code Here

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

      Table table = Table.newTable(doc, 2, 2);
      table.setTableName("Table");
      Cell cell = table.getCellByPosition("B1");
      para = cell.addParagraph("Insert a combo box here.");
      form.createComboBox(para, comboRtg, "combo3", "default text", true);

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

      label.setAnchorType(AnchorType.TO_CHARACTER);
      // label3
      Paragraph para = doc.addParagraph("Insert a Label here.");
      form.createLabel(para, labelRtg, "Label3", "Label3");
      // label4
      Table table1 = Table.newTable(doc, 2, 2);
      Cell cell = table1.getCellByPosition("B1");
      para = cell.addParagraph("Insert a Label here.");
      form.createLabel(para, labelRtg, "Label4", "Label4");
      doc
          .save(ResourceUtilities
              .newTestOutputFile("TestCreateLabel.odt"));
View Full Code Here

    try {
      SpreadsheetDocument odsdoc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("TestSpreadsheetTable.ods"));
   
      int columnindex = 0, rowindex = 3;
      Table table = odsdoc.getTableByName("Sheet1");
      Cell fcell = table.getCellByPosition(columnindex, rowindex);
 
      System.out.println(fcell.getStringValue());
     
      StyleTypeDefinitions.VerticalAlignmentType align = fcell.getVerticalAlignmentType();
      Assert.assertEquals(StyleTypeDefinitions.VerticalAlignmentType.TOP, align);
View Full Code Here

  @Test
  public void testSupportedLinearMeasure() throws Exception{
    try {
      Border borderbase = new Border(Color.LIME, 4.0701, 1.0008, 1.0346, SupportedLinearMeasure.CM);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.TOP, borderbase);
      cell.setBorders(CellBordersType.LEFT, borderbase);

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

  @Test
  public void testCellBordersType() throws Exception{
    try {
      Border borderbase = new Border(Color.LIME, 4.0701, 1.0008, 1.0346, SupportedLinearMeasure.CM);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.TOP, borderbase);
      cell.setBorders(CellBordersType.LEFT, borderbase);

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

  @Test
  public void testGetTable() {
    try {
      doc = PresentationDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_PRESENTATION_FILE));
      Table table = doc.getTableByName("table1");
      Assert.assertNotNull(table);
      String cellText = table.getCellByPosition(4, 1).getDisplayText();
      Assert.assertEquals("11", cellText);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
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.