Exemplo n.º 1
0
  @SuppressWarnings("deprecation")
  public void cleanColumns() {
    this.newCols = CTCols.Factory.newInstance();

    CTCols aggregateCols = CTCols.Factory.newInstance();
    CTCols[] colsArray = worksheet.getColsArray();
    assert (colsArray != null);

    for (CTCols cols : colsArray) {
      for (CTCol col : cols.getColArray()) {
        cloneCol(aggregateCols, col);
      }
    }

    sortColumns(aggregateCols);

    CTCol[] colArray = aggregateCols.getColArray();
    sweepCleanColumns(newCols, colArray, null);

    int i = colsArray.length;
    for (int y = i - 1; y >= 0; y--) {
      worksheet.removeCols(y);
    }
    worksheet.addNewCols();
    worksheet.setColsArray(0, newCols);
  }
Exemplo n.º 2
0
 @SuppressWarnings("deprecation")
 public CTCols addCleanColIntoCols(CTCols cols, CTCol col) {
   CTCols newCols = CTCols.Factory.newInstance();
   for (CTCol c : cols.getColArray()) {
     cloneCol(newCols, c);
   }
   cloneCol(newCols, col);
   sortColumns(newCols);
   CTCol[] colArray = newCols.getColArray();
   CTCols returnCols = CTCols.Factory.newInstance();
   sweepCleanColumns(returnCols, colArray, col);
   colArray = returnCols.getColArray();
   cols.setColArray(colArray);
   return returnCols;
 }
Exemplo n.º 3
0
  public void testAddCleanColIntoCols() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    ColumnHelper helper = new ColumnHelper(worksheet);

    CTCols cols1 = CTCols.Factory.newInstance();
    CTCol col1 = cols1.addNewCol();
    col1.setMin(1);
    col1.setMax(1);
    col1.setWidth(88);
    col1.setHidden(true);
    CTCol col2 = cols1.addNewCol();
    col2.setMin(2);
    col2.setMax(3);
    CTCol col3 = cols1.addNewCol();
    col3.setMin(13);
    col3.setMax(16750);
    assertEquals(3, cols1.sizeOfColArray());
    CTCol col4 = cols1.addNewCol();
    col4.setMin(8);
    col4.setMax(9);
    assertEquals(4, cols1.sizeOfColArray());

    CTCol col5 = CTCol.Factory.newInstance();
    col5.setMin(4);
    col5.setMax(5);
    helper.addCleanColIntoCols(cols1, col5);
    assertEquals(5, cols1.sizeOfColArray());

    CTCol col6 = CTCol.Factory.newInstance();
    col6.setMin(8);
    col6.setMax(11);
    col6.setHidden(true);
    helper.addCleanColIntoCols(cols1, col6);
    assertEquals(6, cols1.sizeOfColArray());

    CTCol col7 = CTCol.Factory.newInstance();
    col7.setMin(6);
    col7.setMax(8);
    col7.setWidth(17.0);
    helper.addCleanColIntoCols(cols1, col7);
    assertEquals(8, cols1.sizeOfColArray());

    CTCol col8 = CTCol.Factory.newInstance();
    col8.setMin(20);
    col8.setMax(30);
    helper.addCleanColIntoCols(cols1, col8);
    assertEquals(10, cols1.sizeOfColArray());

    CTCol col9 = CTCol.Factory.newInstance();
    col9.setMin(25);
    col9.setMax(27);
    helper.addCleanColIntoCols(cols1, col9);

    // TODO - assert something interesting
    assertEquals(12, cols1.sizeOfColArray());
    assertEquals(1, cols1.getColArray(0).getMin());
    assertEquals(16750, cols1.getColArray(11).getMax());
  }
Exemplo n.º 4
0
  public void testCloneCol() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    ColumnHelper helper = new ColumnHelper(worksheet);

    CTCols cols = CTCols.Factory.newInstance();
    CTCol col = CTCol.Factory.newInstance();
    col.setMin(2);
    col.setMax(8);
    col.setHidden(true);
    col.setWidth(13.4);
    CTCol newCol = helper.cloneCol(cols, col);
    assertEquals(2, newCol.getMin());
    assertEquals(8, newCol.getMax());
    assertTrue(newCol.getHidden());
    assertEquals(13.4, newCol.getWidth(), 0.0);
  }
Exemplo n.º 5
0
  public void testSortColumns() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    ColumnHelper helper = new ColumnHelper(worksheet);

    CTCols cols1 = CTCols.Factory.newInstance();
    CTCol col1 = cols1.addNewCol();
    col1.setMin(1);
    col1.setMax(1);
    col1.setWidth(88);
    col1.setHidden(true);
    CTCol col2 = cols1.addNewCol();
    col2.setMin(2);
    col2.setMax(3);
    CTCol col3 = cols1.addNewCol();
    col3.setMin(13);
    col3.setMax(16750);
    assertEquals(3, cols1.sizeOfColArray());
    CTCol col4 = cols1.addNewCol();
    col4.setMin(8);
    col4.setMax(11);
    assertEquals(4, cols1.sizeOfColArray());
    CTCol col5 = cols1.addNewCol();
    col5.setMin(4);
    col5.setMax(5);
    assertEquals(5, cols1.sizeOfColArray());
    CTCol col6 = cols1.addNewCol();
    col6.setMin(8);
    col6.setMax(9);
    col6.setHidden(true);
    CTCol col7 = cols1.addNewCol();
    col7.setMin(6);
    col7.setMax(8);
    col7.setWidth(17.0);
    CTCol col8 = cols1.addNewCol();
    col8.setMin(25);
    col8.setMax(27);
    CTCol col9 = cols1.addNewCol();
    col9.setMin(20);
    col9.setMax(30);
    assertEquals(9, cols1.sizeOfColArray());
    assertEquals(20, cols1.getColArray(8).getMin());
    assertEquals(30, cols1.getColArray(8).getMax());
    ColumnHelper.sortColumns(cols1);
    assertEquals(9, cols1.sizeOfColArray());
    assertEquals(25, cols1.getColArray(8).getMin());
    assertEquals(27, cols1.getColArray(8).getMax());
  }
Exemplo n.º 6
0
 @SuppressWarnings(
     "deprecation") // YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5
                    // support
 public void cleanColumns() {
   this.newCols = CTCols.Factory.newInstance();
   CTCols[] colsArray = worksheet.getColsArray();
   int i = 0;
   for (i = 0; i < colsArray.length; i++) {
     CTCols cols = colsArray[i];
     CTCol[] colArray = cols.getColArray();
     for (int y = 0; y < colArray.length; y++) {
       CTCol col = colArray[y];
       newCols = addCleanColIntoCols(newCols, col);
     }
   }
   for (int y = i - 1; y >= 0; y--) {
     worksheet.removeCols(y);
   }
   worksheet.addNewCols();
   worksheet.setColsArray(0, newCols);
 }