Examples of SpreadsheetDocument


Examples of org.odftoolkit.simple.SpreadsheetDocument

    fcell.setVerticalAlignment(StyleTypeDefinitions.VerticalAlignmentType.BOTTOM);
    align = fcell.getVerticalAlignmentType();
    Assert.assertEquals(StyleTypeDefinitions.VerticalAlignmentType.BOTTOM, align);
    saveods();
    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      StyleTypeDefinitions.VerticalAlignmentType verticalAlignment = cell.getVerticalAlignmentType();
      Assert.assertEquals(StyleTypeDefinitions.VerticalAlignmentType.DEFAULT, verticalAlignment);

      table = ods.getTableByName("Sheet2");
      if (table != null) {
        table.remove();
      }
      table = Table.newTable(ods);
      table.setTableName("Sheet2");
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

    fcell.setValueType("date");
    String valueType = fcell.getValueType();
    Assert.assertEquals("date", valueType);
    saveods();

    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      valueType = cell.getValueType();
      Assert.assertEquals(null, valueType);
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

      Assert.fail(e.getMessage());
    }
    saveods();

    // test value type adapt function.
    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell;
      for (int i = 1; i <= 10; i++) {
        cell = tbl.getCellByPosition("A" + i);
        cell.setDoubleValue(new Double(i));
      }
      cell = tbl.getCellByPosition("A11");
      cell.setFormula("=sum(A1:A10)");
      // contains '#' should be adapted as float.
      cell.setFormatString("#,###");
      Assert.assertEquals("float", cell.getValueType());
      cell = tbl.getCellByPosition("A12");
      cell.setFormula("=sum(A1:A10)");
      // contains '0' should be adapted as float.
      cell.setFormatString("0.00");
      Assert.assertEquals("float", cell.getValueType());
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell;
      for (int i = 1; i <= 10; i++) {
        cell = tbl.getCellByPosition("A" + i);
        cell.setPercentageValue(0.1);
      }
      cell = tbl.getCellByPosition("A11");
      cell.setFormula("=sum(A1:A10)");
      // contains '%'should be adapted as percentage.
      cell.setFormatString("###.0%");
      Assert.assertEquals("percentage", cell.getValueType());
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell;
      for (int i = 1; i <= 10; i++) {
        cell = tbl.getCellByPosition("A" + i);
        cell.setDateValue(Calendar.getInstance());
        cell.setFormatString("yyyy.MM.dd");
      }
      cell = tbl.getCellByPosition("A11");
      cell.setFormula("=max(A1:A10)");
      // contains 'y' 'M' 'd' should be adapted as date.
      cell.setFormatString("yyyy.MM.dd");
      Assert.assertEquals("date", cell.getValueType());
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell;
      for (int i = 1; i <= 10; i++) {
        cell = tbl.getCellByPosition("A" + i);
        cell.setTimeValue(Calendar.getInstance());
        cell.setFormatString("yyyy.MM.dd HH:mm:ss");
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

    loadOutputSpreadsheet();
    table = odsdoc.getTableByName("Sheet1");
    fcell = table.getCellByPosition(columnindex, rowindex);
    Assert.assertEquals(expectedColor.toString(), fcell.getCellBackgroundColor().toString());

    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      Color actualBackColor = cell.getCellBackgroundColor();
      Assert.assertEquals("#ffffff", actualBackColor.toString());
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

    }
  }

  @Test
  public void testSetDefaultCellStyle() {
    SpreadsheetDocument outputDocument;
    OdfContentDom contentDom; // the document object model for content.xml
    // the office:automatic-styles element in content.xml
    OdfOfficeAutomaticStyles contentAutoStyles;
    OdfStyle style;
    String noaaDateStyleName;
    String noaaTempStyleName;

    try {
      outputDocument = SpreadsheetDocument.newSpreadsheetDocument();
      contentDom = outputDocument.getContentDom();
      contentAutoStyles = contentDom.getOrCreateAutomaticStyles();

      OdfNumberDateStyle dateStyle = new OdfNumberDateStyle(contentDom, "yyyy-MM-dd", "numberDateStyle", null);
      OdfNumberStyle numberStyle = new OdfNumberStyle(contentDom, "#0.00", "numberTemperatureStyle");
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

  }

  @Test
  public void testColumnWidthCompareNewTableWithGetCellByPosition() {
    try {
      SpreadsheetDocument odsDoc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = Table.newTable(odsDoc, 20, 20);
      table.setTableName("Table1");
      double width1 = table.getColumnByIndex(0).getWidth();
      table = Table.newTable(odsDoc);
      table.setTableName("Table2");
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

      for (int i = 0; i < columnCount; i++) {
        columnLabels[i] = "ColumnHeader" + i;
      }
      double[][] doubleArray = null;
      String[][] stringArray = null;
      SpreadsheetDocument spreadsheet = SpreadsheetDocument.newSpreadsheetDocument();
      Table table1 = Table.newTable(spreadsheet, null, null, doubleArray);
      Assert.assertEquals(0, table1.getHeaderColumnCount());
      Assert.assertEquals(0, table1.getHeaderRowCount());
      // row count should be DEFAULT_ROW_COUNT 2
      Assert.assertEquals(2, table1.getRowCount());
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

  @Test
  public void testNewTableWithoutHeaderColumn() {
    try {
      // reproduce bug 145
      SpreadsheetDocument spreadsheet = SpreadsheetDocument.newSpreadsheetDocument();
      Table sheet = Table.newTable(spreadsheet, 3, 5);
      TableTableHeaderColumnsElement headers = OdfElement.findFirstChildNode(
          TableTableHeaderColumnsElement.class, sheet.getOdfElement());
      if (headers != null) {
        for (Node n : new DomNodeList(headers.getChildNodes())) {
View Full Code Here

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

Examples of org.odftoolkit.simple.SpreadsheetDocument

    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
TOP
Copyright © 2018 www.massapi.com. 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.