Examples of SpreadsheetDocument


Examples of org.odftoolkit.simple.SpreadsheetDocument

  }

  @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

Examples of org.odftoolkit.simple.SpreadsheetDocument

  public void testCellSizeOptimal() {
    Font font1Base = new Font("Arial", FontStyle.REGULAR, 6, Color.GREEN, TextLinePosition.REGULAR);
    Font font2Base = new Font("Times New Roman", FontStyle.REGULAR, 13, Color.RED, TextLinePosition.REGULAR);
    Font font3Base = new Font("SimSun", FontStyle.REGULAR, 17, Color.BLUE, TextLinePosition.REGULAR);
    try {
      final SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      final Table table = doc.addTable();
      final String contentStr = "This is a long text content.";
     
      // basically the default font is of Arial type, so assume the default family
      final String nfFamilyName = "Arial";
     
      if (isFontAvailable(nfFamilyName)) {
        checkCellWidth(table.getCellByPosition(0, 0), null, 44.0977, contentStr);
      }
      if (isFontAvailable(font1Base.getFamilyName())) {
        checkCellWidth(table.getCellByPosition(1, 1), font1Base, 24.3424, contentStr);
      }
      if (isFontAvailable(font2Base.getFamilyName())) {
        checkCellWidth(table.getCellByPosition(2, 2), font2Base, 49.7414, contentStr);
      }
      if (isFontAvailable(font3Base.getFamilyName())) {
        checkCellWidth(table.getCellByPosition(3, 3), font3Base, 88.899, contentStr);
      }
      doc.save(ResourceUtilities.newTestOutputFile("testCellSizeOptimal.ods"));
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

  @Test
  public void testGetCountry() {
    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);

      CellStyleHandler cellHandler = cell.getStyleHandler();
      cellHandler.setCountry("English", Document.ScriptType.CJK);
      //validate
      String country = cellHandler.getCountry(Document.ScriptType.CJK);
      Assert.assertEquals("English", country);
     
      //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

Examples of org.odftoolkit.simple.SpreadsheetDocument

  @Test
  public void testGetLanguage() {
    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);

      CellStyleHandler cellHandler = cell.getStyleHandler();
      cellHandler.setLanguage("English", Document.ScriptType.WESTERN);
      //validate
      String language = cellHandler.getLanguage(Document.ScriptType.WESTERN);
      System.out.println(language);
      Assert.assertEquals("English", language);
     
      //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

Examples of org.odftoolkit.simple.SpreadsheetDocument

  @Test
  public void testSetColor() {
    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);

      CellStyleHandler cellHandler = cell.getStyleHandler();
      cellHandler.setBackgroundColor(Color.RED);
      //validate
      Color red = cellHandler.getBackgroundColor();
      Assert.assertEquals(Color.RED.toString(), red.toString());
     
      //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

Examples of org.odftoolkit.simple.SpreadsheetDocument

 
  @Test
  public void testSetBorder() {
    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);
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

 
  @Test
  public void testIsTextWrapped() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.CM);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      Cell cell = table.getCellByPosition("A14");
      cell.setStringValue("testIsTextWrapped.");
      cell.setBorders(CellBordersType.ALL_FOUR, borderbase);

      CellStyleHandler cellHandler = cell.getStyleHandler();
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

    cellRange1.setCellRangeName("TimeCellRange");
    cellRange1.merge();

    saveods("CellRangeName");
    try {
      SpreadsheetDocument saveddos = (SpreadsheetDocument) SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename + "CellRangeName.ods"));
      Table savedSheet = saveddos.getTableByName("Sheet1");
      CellRange namedCellRange = savedSheet.getCellRangeByName("TimeCellRange");
      Cell cell = namedCellRange.getCellByPosition("A1");
      Assert.assertTrue(cell.getRowSpannedNumber() == 6);
    } catch (Exception e) {
      Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

  }

  @Test
  public void testMergeExpandCellRange() {
    try {
      SpreadsheetDocument ods = SpreadsheetDocument.newSpreadsheetDocument();
      // the doc contain the table which only have one column and one row
      // element
      Table table = ods.getTableByName("Sheet1");
      int nCols = table.getColumnCount();
      int nRows = table.getRowCount();
      Assert.assertTrue(nCols == 1);
      Assert.assertTrue(nRows == 1);
      CellRange cellRange = table.getCellRangeByPosition("A1", "E1");
      Cell cell = table.getCellByPosition("A1");
      cell.setStringValue("Merge A1:E1");
      cellRange.merge();
      Table table2 = Table.newTable(ods, 1, 1);
      table2.setTableName("Sheet2");
      CellRange cellRange2 = table2.getCellRangeByPosition("A1", "F3");
      Cell cell2 = table2.getCellByPosition("A1");
      cell2.setStringValue("Merge A1:F3");
      cellRange2.merge();
      ods.save(ResourceUtilities.newTestOutputFile(filename + "MergeExpandCell.ods"));
      table = ods.getTableByName("Sheet1");
      Assert.assertTrue(table.getColumnCount() == 5);
      Assert.assertTrue(table.getRowCount() == 1);
      table = ods.getTableByName("Sheet2");
      Assert.assertTrue(table.getColumnCount() == 6);
      Assert.assertTrue(table.getRowCount() == 3);
      TextDocument odt = TextDocument.newTextDocument();
      Table swTable = Table.newTable(odt, 1, 5);
      CellRange swCellRange = swTable.getCellRangeByPosition("A1", "E2");
View Full Code Here

Examples of org.odftoolkit.simple.SpreadsheetDocument

    // 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
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.