Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.SpreadsheetDocument


  }

  @Test
  public void testGetColumnCountWithColumnsInDocument() {
    try {
      SpreadsheetDocument sDoc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("Spreadsheet with Embeded Chart.ods"));
      List<Document> charts = sDoc.getEmbeddedDocuments(OdfMediaType.CHART);
      for (Document chart : charts) {
        // "local-table" is the inner table name of chart document with
        // 2 columns
        Table localTable = chart.getTableByName("local-table");
        int columnCount = localTable.getColumnCount();
View Full Code Here


    Assert.assertEquals("stringM15", cell.getStringValue());
  }

  @Test
  public void testGetCellWithAutoExtend() {
    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      tbl.setTableName("Tests");
      Cell cell = tbl.getCellByPosition(5, 5);
      Assert.assertNotNull(cell);
      Assert.assertEquals(6, tbl.getRowCount());
      Assert.assertEquals(6, tbl.getColumnCount());
View Full Code Here

  @Test
  public void testAppendRow() {
    OdfFileDom dom;
    try {
      SpreadsheetDocument odsDoc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("TestODSAppendRow.ods"));
      dom = odsDoc.getContentDom();
      NodeList tablelist = dom.getElementsByTagNameNS(OdfDocumentNamespace.TABLE.getUri(), "table");
      for (int i = 0; i < tablelist.getLength(); i++) {
        mOdsTable = (TableTableElement) tablelist.item(i);
        testAppendRow(mOdsTable);
      }
      odsDoc.save(ResourceUtilities.newTestOutputFile("TestODSAppendRowOutput.ods"));

      TextDocument odtDoc = TextDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("TestODTAppendRow.odt"));
      dom = odtDoc.getContentDom();
      tablelist = dom.getElementsByTagNameNS(OdfDocumentNamespace.TABLE.getUri(), "table");
View Full Code Here

    }
  }

  @Test
  public void testAppendRowsWithCoveredCell() {
    SpreadsheetDocument odsDoc = null;
    Table table = null;
    try {
      odsDoc = SpreadsheetDocument.newSpreadsheetDocument();
      table = Table.newTable(odsDoc);
      mergeCells(table, 1, 1, 3, 2);
View Full Code Here

  }

  @Test
  public void testAppendRowsWithRowsRepeated() {
    SpreadsheetDocument odsDoc = null;
    Table table = null;
    try {
      odsDoc = SpreadsheetDocument.newSpreadsheetDocument();
      table = Table.newTable(odsDoc, 1, 1);
      table.appendRows(12);
View Full Code Here

    }
  }

  @Test
  public void testAppendColumnsWithColumnsRepeated() {
    SpreadsheetDocument odsDoc = null;
    Table table = null;
    try {
      odsDoc = SpreadsheetDocument.newSpreadsheetDocument();
      table = Table.newTable(odsDoc, 1, 1);
      table.appendColumns(12);
View Full Code Here

  // Bug 97 - Row.getCellAt(int) returns null when the cell is a repeat cell
  @Test
  public void testGetCellAt() {
    try {
      SpreadsheetDocument doc = (SpreadsheetDocument) SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("testGetCellAt.ods"));
      Table odfTable = doc.getTableList().get(0);
      Row valueRows = odfTable.getRowByIndex(0);
      for (int i = 0; i < 4; i++) {
        Cell cell = valueRows.getCellByIndex(i);
        Assert.assertNotNull(cell);
        int value = cell.getDoubleValue().intValue();
View Full Code Here

    }
  }

  @Test
  public void testDeleteRowsOnEmptyTable() throws Exception {
    SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
    Table odfTable = doc.addTable();
    // two rows are created by default
    Assert.assertEquals(2, odfTable.getRowCount());
    while(odfTable.getRowCount() != 0) {
      odfTable.removeRowsByIndex(0, 1);
    }
View Full Code Here

  }

  @Test
  public void testSetGetFont() {
    try {
      SpreadsheetDocument document;
      document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table1 = document.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      cell1.setStringValue("abcdefg");
      Font font1 = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 12, Color.BLACK,
          StyleTypeDefinitions.TextLinePosition.THROUGH);
      cell1.setFont(font1);
      Font font11 = cell1.getFont();
      System.out.println(font11);
      if (!font11.equals(font1))
        Assert.fail();

      Cell cell2 = table1.getCellByPosition("A2");
      cell2.setStringValue("redstring");
      Font font2 = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 12, Color.RED,
          StyleTypeDefinitions.TextLinePosition.UNDER);
      cell2.setFont(font2);
      Font font22 = cell2.getFont();
      System.out.println(font22);
      if (!font22.equals(font2))
        Assert.fail();
      document.save(ResourceUtilities.newTestOutputFile("TestSetGetFont.ods"));
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail();
    }
  }
View Full Code Here

  }

  @Test
  public void testSetGetBorder() {
    try {
      SpreadsheetDocument document;
      document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table1 = document.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      cell1.setStringValue("four border");
      Border border = new Border(Color.RED, 1, StyleTypeDefinitions.SupportedLinearMeasure.PT);
      cell1.setBorders(CellBordersType.ALL_FOUR, border);
      Border bottomBorder = cell1.getStyleHandler().getBorder(CellBordersType.BOTTOM);
      Assert.assertEquals(border, bottomBorder);

      Cell cell2 = table1.getCellByPosition("C2");
      cell2.setStringValue("top bottom");
      Border border2 = new Border(Color.BLUE, 5, 1, 2, StyleTypeDefinitions.SupportedLinearMeasure.PT);
      cell2.setBorders(CellBordersType.TOP_BOTTOM, border2);
      Border bottomBorder2 = cell2.getStyleHandler().getBorder(CellBordersType.BOTTOM);
      Assert.assertEquals(border2, bottomBorder2);
      Border bottomBorder22 = cell2.getStyleHandler().getBorder(CellBordersType.LEFT);
      Assert.assertEquals(Border.NONE, bottomBorder22);
      document.save(ResourceUtilities.newTestOutputFile("TestSetGetBorder.ods"));
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail();
    }
  }
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.SpreadsheetDocument

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.