/**
   * The reference for the cell in the top-left part of the table (see Open Office XML Part 4:
   * chapter 3.5.1.2, attribute ref)
   *
   * @return
   */
  public CellReference getStartCellReference() {

    if (startCellReference == null) {
      String ref = ctTable.getRef();
      String[] boundaries = ref.split(":");
      String from = boundaries[0];
      startCellReference = new CellReference(from);
    }
    return startCellReference;
  }
  /**
   * The reference for the cell in the bottom-right part of the table (see Open Office XML Part 4:
   * chapter 3.5.1.2, attribute ref)
   *
   * @return
   */
  public CellReference getEndCellReference() {

    if (endCellReference == null) {

      String ref = ctTable.getRef();
      String[] boundaries = ref.split(":");
      String from = boundaries[1];
      endCellReference = new CellReference(from);
    }
    return endCellReference;
  }
  public List<XSSFXmlColumnPr> getXmlColumnPrs() {

    if (xmlColumnPr == null) {
      xmlColumnPr = new Vector<XSSFXmlColumnPr>();
      for (CTTableColumn column : ctTable.getTableColumns().getTableColumnArray()) {
        if (column.getXmlColumnPr() != null) {
          XSSFXmlColumnPr columnPr = new XSSFXmlColumnPr(this, column, column.getXmlColumnPr());
          xmlColumnPr.add(columnPr);
        }
      }
    }
    return xmlColumnPr;
  }
  /**
   * Calculates the xpath of the root element for the table. This will be the common part of all the
   * mapping's xpaths
   *
   * @return the xpath of the table's root element
   */
  public String getCommonXpath() {

    if (commonXPath == null) {

      String[] commonTokens = {};

      for (CTTableColumn column : ctTable.getTableColumns().getTableColumnArray()) {
        if (column.getXmlColumnPr() != null) {
          String xpath = column.getXmlColumnPr().getXpath();
          String[] tokens = xpath.split("/");
          if (commonTokens.length == 0) {
            commonTokens = tokens;

          } else {
            int maxLenght =
                commonTokens.length > tokens.length ? tokens.length : commonTokens.length;
            for (int i = 0; i < maxLenght; i++) {
              if (!commonTokens[i].equals(tokens[i])) {
                List<String> subCommonTokens = Arrays.asList(commonTokens).subList(0, i);

                String[] container = {};

                commonTokens = subCommonTokens.toArray(container);
                break;
              }
            }
          }
        }
      }

      commonXPath = "";

      for (int i = 1; i < commonTokens.length; i++) {
        commonXPath += "/" + commonTokens[i];
      }
    }

    return commonXPath;
  }
 /**
  * the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)
  *
  * @return
  */
 public long getNumerOfMappedColumns() {
   return ctTable.getTableColumns().getCount();
 }