Examples of OdfSpreadsheetDocument


Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

    if (inPath.getName().endsWith(".xlsx")) {
      XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(inPath));
      return processSampleInputXLSX(wb, u, manager, libraryNamingScheme);
    }
    else if (inPath.getName().endsWith(".ods")) {
      OdfSpreadsheetDocument oDoc = (OdfSpreadsheetDocument) OdfDocument.loadDocument(inPath);
      return processSampleInputODS(oDoc, u, manager, libraryNamingScheme);
    }
    else {
      throw new UnsupportedOperationException("Cannot process bulk input files other than xls, xlsx, and ods.");
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

  }

  @Test
  public void testNewTableWithArrayData() {
    try {
      OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.newSpreadsheetDocument();

      // reproduce bug 121
      int rowCount = 10, columnCount = 4;
      String[] rowLabels = getTestTableRowLabel(rowCount);
      String[] columnLabels = getTestTableColumnLabel(columnCount);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

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

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

    Assert.assertEquals("stringM15", cell.getStringValue());
  }

  @Test
  public void testGetCellWithAutoExtend() {
    OdfSpreadsheetDocument ods;
    try {
      ods = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      tbl.setTableName("Tests");
      OdfTableCell cell = tbl.getCellByPosition(5, 5);
      Assert.assertNotNull(cell);
      Assert.assertEquals(6, tbl.getRowCount());
      Assert.assertEquals(6, tbl.getColumnCount());
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

  // Bug 97 - OdfTableRow.getCellAt(int) returns null when the cell is a repeat cell
  @Test
  public void testGetCellAt() {
    try {
      OdfSpreadsheetDocument doc = (OdfSpreadsheetDocument) OdfSpreadsheetDocument.loadDocument(ResourceUtilities.getAbsolutePath("testGetCellAt.ods"));
      OdfTable odfTable = doc.getTableList().get(0);
      OdfTableRow valueRows = odfTable.getRowByIndex(0);
      for (int i = 0; i < 4; i++) {
        OdfTableCell cell = valueRows.getCellByIndex(i);
        Assert.assertNotNull(cell);
        int value = cell.getDoubleValue().intValue();
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

    fcell.setHorizontalAlignment("right");
    align = fcell.getHorizontalAlignment();
    Assert.assertEquals("end", align);
    saveods();

    OdfSpreadsheetDocument ods;
    try {
      ods = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell cell = tbl.getCellByPosition(0, 0);
      String horizonAlignment = cell.getHorizontalAlignment();
      Assert.assertEquals(null, horizonAlignment);
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

    fcell.setVerticalAlignment("bottom");
    align = fcell.getVerticalAlignment();
    Assert.assertEquals("bottom", align);
    saveods();
    OdfSpreadsheetDocument ods;
    try {
      ods = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell cell = tbl.getCellByPosition(0, 0);
      String verticalAlignment = cell.getVerticalAlignment();
      Assert.assertEquals(null, verticalAlignment);
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

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

    OdfSpreadsheetDocument ods;
    try {
      ods = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell 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.odfdom.doc.OdfSpreadsheetDocument

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

    //test value type adapt function.
    OdfSpreadsheetDocument ods;
    try {
      ods = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell 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 = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell 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 = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell 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 = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell 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.odfdom.doc.OdfSpreadsheetDocument

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

    OdfSpreadsheetDocument ods;
    try {
      ods = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell 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
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.