Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Cell


  public void testGetSetName() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, StyleTypeDefinitions.TextLinePosition.REGULAR, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("testGetFontStyle.");
     
      TextProperties textProperties = cell.getStyleHandler().getTextPropertiesForWrite();
      textProperties.setFontName("fontname");
     
      //validate
      String fontName = textProperties.getFontName();
      Assert.assertEquals("fontname", fontName);
View Full Code Here


      pDoc.save(ResourceUtilities.newTestOutputFile("imagep.odp"));

      // new image in a table
      TextDocument sDoc = TextDocument.newTextDocument();
      Table table1 = sDoc.addTable(2, 2);
      Cell cell1 = table1.getCellByPosition(0, 0);
      Image image3 = cell1.setImage(ResourceUtilities.getURI("image_list_item.png"));
      image3.setHorizontalPosition(FrameHorizontalPosition.LEFT);
      image3.setHyperlink(new URI("http://odftoolkit.org"));
      Assert.assertEquals("http://odftoolkit.org", image3.getHyperlink().toString());
      sDoc.save(ResourceUtilities.newTestOutputFile("imges.odt"));

      SpreadsheetDocument sheet = SpreadsheetDocument.newSpreadsheetDocument();
      Table table2 = sheet.getTableList().get(0);
      Cell cell2 = table2.getCellByPosition(1, 1);
      Image image4 = cell2.setImage(ResourceUtilities.getURI("image_list_item.png"));
      sheet.save(ResourceUtilities.newTestOutputFile("imgesheet.ods"));
      Image aImage4 = cell2.getImage();
      Assert.assertEquals(image4, aImage4);

    } catch (Exception e) {
      Logger.getLogger(ImageTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
View Full Code Here

  public void testGetSetNameParam() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, StyleTypeDefinitions.TextLinePosition.REGULAR, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("testGetFontStyle.");
     
      TextProperties textProperties = cell.getStyleHandler().getTextPropertiesForWrite();
      textProperties.setFontName("fontname", Document.ScriptType.WESTERN);
     
      //validate
      String fontName = textProperties.getFontName(Document.ScriptType.WESTERN);
      Assert.assertEquals("fontname", fontName);
View Full Code Here

  public void testGetHorizontalPosition() {
    try {
      // new image in a table
      TextDocument sDoc = TextDocument.newTextDocument();
      Table table1 = sDoc.addTable(2, 2);
      Cell cell1 = table1.getCellByPosition(0, 0);
      Image image3 = cell1.setImage(ResourceUtilities.getURI("image_list_item.png"));
      image3.setHorizontalPosition(FrameHorizontalPosition.LEFT);
      Assert.assertEquals(FrameHorizontalPosition.LEFT, image3.getHorizontalPosition());
     
      //save
      //sDoc.save(ResourceUtilities.newTestOutputFile("imges.odt"));
View Full Code Here

  public void testSetVerticalPosition() {
    try {
      // new image in a table
      TextDocument sDoc = TextDocument.newTextDocument();
      Table table1 = sDoc.addTable(2, 2);
      Cell cell1 = table1.getCellByPosition(0, 0);
      Image image3 = cell1.setImage(ResourceUtilities.getURI("image_list_item.png"));
      image3.setVerticalPosition(FrameVerticalPosition.BELOW);
     
      Assert.assertEquals(FrameVerticalPosition.BELOW, image3.getVerticalPosition());
     
      //save
View Full Code Here

  public void testSetFont() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, StyleTypeDefinitions.TextLinePosition.REGULAR, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      //cell.setFont(font);
      cell.setStringValue("testGetFontStyle.");
     
      TextProperties textProperties = cell.getStyleHandler().getTextPropertiesForWrite();
      textProperties.setFont(font);
     
      //validate
      Font font1 = textProperties.getFont();
      Assert.assertEquals(font, font1);
View Full Code Here

  public void testSetFontName() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, StyleTypeDefinitions.TextLinePosition.REGULAR, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      //cell.setFont(font);
      font.setFamilyName("Chinese");
      cell.setStringValue("testGetFontStyle.");
     
      TextProperties textProperties = cell.getStyleHandler().getTextPropertiesForWrite();
      textProperties.setFont(font);
     
      //validate
      String fontname = textProperties.getFontName();
      Assert.assertEquals("Chinese", fontname);
View Full Code Here

          "TextBox2", "TextBox2", false);
      textBox.setAnchorType(AnchorType.TO_CHARACTER);

      // textbox3
      Table table = Table.newTable(doc, 2, 2);
      Cell cell = table.getCellByPosition("B1");
      para = cell.addParagraph("Insert a text box here.");
      form.createTextBox(para, textBoxRtg, "TextBox3", "TextBox3", false);
     
      doc.save(ResourceUtilities
          .newTestOutputFile("TestCreateTextBox.odt"));
View Full Code Here

      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

    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) {
      e.printStackTrace();
      Assert.fail();
    }
View Full Code Here

TOP

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

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.