Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Table


    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);

      //validate
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
View Full Code Here


    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
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
      NamedNodeMap attr = styleCell.mElement.getAttributes();
View Full Code Here

  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();
View Full Code Here

  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();
View Full Code Here

  }
 
        @Test
  public void testSettingNullBackgroundOnProperties() throws Exception {
            SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
            Table table = doc.getTableByName("Sheet1");
            Cell cell = table.getCellByPosition(1, 1);
            cell.setCellBackgroundColor(Color.BLACK);
            // setting null resets the element, see ODFTOOLKIT-326
            cell.getStyleHandler().getTableCellPropertiesForWrite().setBackgroundColor(null);
            Assert.assertNull(cell.getStyleHandler().getTableCellPropertiesForRead().getBackgroundColor());
            // defaulting to white when color is null
            Assert.assertEquals(Color.WHITE, cell.getCellBackgroundColor());
            Cell newCell = table.appendRow().getCellByIndex(1);
            Assert.assertNull(newCell.getStyleHandler().getTableCellPropertiesForRead().getBackgroundColor());
            Assert.assertEquals(Color.WHITE, newCell.getCellBackgroundColor());
        }
View Full Code Here

        }
       
        @Test
        public void testSettingBlackBackgroundOnProperties() throws Exception {
            SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
            Table table = doc.getTableByName("Sheet1");
            Cell cell = table.getCellByPosition(1, 1);
            cell.setCellBackgroundColor(Color.BLUE);
            cell.getStyleHandler().getTableCellPropertiesForWrite().setBackgroundColor(Color.BLACK);
            Assert.assertEquals(Color.BLACK, cell.getStyleHandler().getTableCellPropertiesForRead().getBackgroundColor());
            Assert.assertEquals(Color.BLACK, cell.getCellBackgroundColor());
            Cell newCell = table.appendRow().getCellByIndex(1);
            Assert.assertEquals(Color.BLACK, newCell.getStyleHandler().getBackgroundColor());
        }
View Full Code Here

        }
       
        @Test
        public void testSettingNullBackgroundOnCell() throws Exception {
            SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
            Table table = doc.getTableByName("Sheet1");
            Cell cell = table.getCellByPosition(1, 1);
            cell.setCellBackgroundColor((Color) null);
            Assert.assertNull(cell.getStyleHandler().getTableCellPropertiesForRead().getBackgroundColor());
            Assert.assertEquals(Color.WHITE, cell.getCellBackgroundColor());
        }
View Full Code Here

  @Test
  public void testGetSheetByIndexOrName() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(TEST_FILE_NAME));
      Table table1 = document.getSheetByName("Sheet2");
      Table table2 = document.getSheetByIndex(1);
      Assert.assertEquals("Sheet2", table1.getTableName());
      Assert.assertEquals("Sheet2", table2.getTableName());
    } catch (Exception e) {
      Logger.getLogger(SpreadsheetTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

  public void testInsertSheet() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(TEST_FILE_NAME));
      int oldCount = document.getSheetCount();
      Table table = document.insertSheet(0);
      Assert.assertFalse("Sheet1".equals(table.getTableName()));
      int newCount = document.getSheetCount();
      Assert.assertEquals(1, newCount - oldCount);
      table = document.insertSheet(document.getSheetByName("Sheet1"), 2);
      Assert.assertEquals(table.getTableName(), document.getSheetByIndex(2).getTableName());
      document.save(ResourceUtilities.newTestOutputFile("Output_"+TEST_FILE_NAME));
     
      //data table from difference document.
      document = SpreadsheetDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_FILE_NAME));
      Table sheet1 = document.getSheetByName("Sheet1");
      SpreadsheetDocument document1 = SpreadsheetDocument.newSpreadsheetDocument();
      table = document1.insertSheet(sheet1, 0);
      Assert.assertEquals(sheet1.getCellByPosition("E3").getDisplayText(), table.getCellByPosition("E3").getDisplayText());
      document1.save(ResourceUtilities.newTestOutputFile("Output2_"+TEST_FILE_NAME));
    } catch (Exception e) {
      Logger.getLogger(SpreadsheetTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

  @Test
  public void testAppendAndRemoveSheet() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(TEST_FILE_NAME));
      Table table = document.appendSheet("Sheet4");
      Assert.assertEquals("Sheet4", table.getTableName());
      table = document.appendSheet(document.getSheetByName("Sheet1"), "Sheet5");
      Assert.assertEquals("Sheet5", table.getTableName());
      document.save(ResourceUtilities.newTestOutputFile("Output_"+TEST_FILE_NAME));
     
      //reload
      document = SpreadsheetDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Output_"+TEST_FILE_NAME));
      document.removeSheet(4);
      Assert.assertNull(document.getSheetByName("Sheet5"));
      document.removeSheet(3);
      Assert.assertNull(document.getSheetByName("Sheet4"));
     
      //data table from difference document.
      document = SpreadsheetDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_FILE_NAME));
      Table sheet1 = document.getSheetByName("Sheet1");
      SpreadsheetDocument document1 = SpreadsheetDocument.newSpreadsheetDocument();
      table = document1.appendSheet(sheet1, "SheetA");
      Assert.assertEquals(sheet1.getCellByPosition("E3").getDisplayText(), table.getCellByPosition("E3").getDisplayText());
      document1.save(ResourceUtilities.newTestOutputFile("Output2_"+TEST_FILE_NAME));
    } catch (Exception e) {
      Logger.getLogger(SpreadsheetTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

TOP

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

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.