Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.SpreadsheetDocument


  public void testSetBorders() {
    try {
     
        Border borderbase = new Border(Color.LIME, 1.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.BOTTOM, borderbase);
      cell.setBorders(CellBordersType.RIGHT, borderbase);
      cell.setBorders(CellBordersType.DIAGONALTLBR, borderbase);

      //verification
      Border base = cell.getBorder(CellBordersType.BOTTOM);
      base = cell.getBorder(CellBordersType.RIGHT);
      base = cell.getBorder(CellBordersType.DIAGONALTLBR);
      Assert.assertEquals(borderbase, base);
      Assert.assertEquals(StyleTypeDefinitions.LineType.SINGLE, borderbase.getLineStyle());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here


  public void testSetBorders_NONE() {
    try {
     
        Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(0, 0);
      //cell.setBorders(CellBordersType.DIAGONAL_LINES, borderbase);
      cell.setBorders(CellBordersType.RIGHT, borderbase);
View Full Code Here

  public void testSetBorders_DIAGONAL_LINES() {
    try {
     
        Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(0, 0);
      cell.setBorders(CellBordersType.DIAGONAL_LINES, borderbase);

      //validate
View Full Code Here

  @Test
  public void testGetBorder() {
    try {
      Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.ALL_FOUR, borderbase);

      //validate
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
      Border bor = styleCell.getBorder();
      Assert.assertEquals(borderbase, bor);
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

  @Test
  public void testGetLeftBorder() {
    try {
      Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.DOUBLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.RIGHT, borderbase);

      //validate
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
      Border bor = styleCell.getRightBorder();
      Assert.assertEquals(borderbase, bor);
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

    // get type
    align = fcell.getHorizontalAlignmentType();
    Assert.assertEquals(HorizontalAlignmentType.RIGHT, align);
    saveods();

    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      HorizontalAlignmentType horizonAlignment = cell.getHorizontalAlignmentType();
      Assert.assertEquals(HorizontalAlignmentType.DEFAULT, horizonAlignment);

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

    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

    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

      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

    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

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.