Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Table


        return join(lines, System.getProperty("line.separator"));
    }

    private static Collection<String> parseTable(Node item) {
        ArrayList<String> lines = new ArrayList<String>();
        Table table = Table.getInstance((TableTableElement) item);
        for (Row row : table.getRowList()) {
            lines.add(parseTableRow(row));
        }
        return lines;
    }
View Full Code Here


  @Test
  public void testGetSheetByIndex() throws Exception{
    File file = new File(ResourceUtilities.getAbsolutePath("TestSpreadsheetTable.ods"));
    SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
    //index < 0 , Not expected, table ==null
    Table tablenull = spDocument.getSheetByIndex(-1);
    Assert.assertTrue((tablenull == null));
    //index > 0
    //index = 0
    Table tableSheet0 = spDocument.getSheetByIndex(0);
    Assert.assertTrue((tableSheet0 != null));
    Assert.assertEquals("Sheet1", tableSheet0.getTableName());
    Assert.assertEquals(29, tableSheet0.getColumnCount());
    //index = 1
    Table tableSheet1 = spDocument.getSheetByIndex(1);
    Assert.assertTrue((tableSheet1 != null));
    Assert.assertEquals("Sheet2", tableSheet1.getTableName());
    Assert.assertEquals(1, tableSheet1.getColumnCount());
  }
View Full Code Here

  @Test
  public void testInsertSheet() throws Exception{
    File file = new File(ResourceUtilities.getAbsolutePath(TEST_FILE));
    SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
    //index <0 , Not expected
    Table table = spDocument.insertSheet(-1);
    Assert.assertNull(table);
    //index >= sheet count
    Table tableb = spDocument.insertSheet(11);
    Assert.assertNull(tableb);
   
    //index is within the law
    Table tab = spDocument.getSheetByName("tabellDemo2");
    if(tab != null){
      for(int i=0;i<spDocument.getSheetCount();i++){
        if(tab.equals(spDocument.getSheetByIndex(i)))
          spDocument.removeSheet(i);
      }
    }
    Table tablea = spDocument.insertSheet(0);
    Column col = tablea.appendColumn();
    col.setWidth(12.99);
    Column col2 = tablea.appendColumn();
    col.setWidth(12.);
    tablea.setTableName("tabellDemo2");
    Assert.assertEquals("tabellDemo2", tablea.getTableName());
    spDocument.save(ResourceUtilities.getAbsolutePath(TEST_FILE));
   
  }
View Full Code Here

  @Test
  public void testRemoveSheet() throws Exception{
    File file = new File(ResourceUtilities.getAbsolutePath(TEST_FILE));
    SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
    //index <0 , Not expected
    Table table = spDocument.insertSheet(-1);
    Assert.assertNull(table);
    //index >= sheet count
    Table tableb = spDocument.insertSheet(11);
    Assert.assertNull(tableb);
   
    //index is within the law
    Table tab = spDocument.getSheetByName("tabellDemo2");
    if(tab != null){
      for(int i=0;i<spDocument.getSheetCount();i++){
        if(tab.equals(spDocument.getSheetByIndex(i)))
          spDocument.removeSheet(i);
      }
    }
    Table tablea = spDocument.insertSheet(0);
    Column col = tablea.appendColumn();
    col.setWidth(12.99);
    Column col2 = tablea.appendColumn();
    col.setWidth(12.);
    tablea.setTableName("tabellDemo2");
    Assert.assertEquals("tabellDemo2", tablea.getTableName());
    spDocument.removeSheet(0);
    Table tablem = spDocument.getSheetByIndex(0);
    Assert.assertNotSame(tablea, tablem);
   
    //spDocument.save(ResourceUtilities.getAbsolutePath(TEST_FILE));
  }
View Full Code Here

  @Test
  public void testGetSheetByIndex2() throws Exception{
    File file = new File(ResourceUtilities.getAbsolutePath(TEST_FILE));
    SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
    //index <0 , Not expected
    Table table = spDocument.insertSheet(-1);
    Assert.assertNull(table);
    //index >= sheet count
    Table tableb = spDocument.insertSheet(11);
    Assert.assertNull(tableb);
   
    //index is within the law
    Table tab = spDocument.getSheetByName("tabellDemo1");
    if(tab != null)
      tab.remove();
   
    Table taba = spDocument.getSheetByName("Tabelle1");
    Table tablea = spDocument.insertSheet(taba,0);
    tablea.setTableName("tabellDemo1");
    Assert.assertEquals("tabellDemo1", tablea.getTableName());
    Table tablem = spDocument.getSheetByIndex(0);
    Assert.assertEquals(tablea, tablem);
   
    spDocument.save(ResourceUtilities.getAbsolutePath(TEST_FILE));
   
  }
View Full Code Here

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

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.