Search in sources :

Example 6 with CTCol

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol in project poi by apache.

the class TestColumnHelper method testAddCleanColIntoCols.

@Test
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());
    // No overlap
    helper.addCleanColIntoCols(cols1, createCol(4, 5));
    assertEquals(5, cols1.sizeOfColArray());
    // Overlaps with 8 - 9 (overlap and after replacements required)
    CTCol col6 = createCol(8, 11);
    col6.setHidden(true);
    helper.addCleanColIntoCols(cols1, col6);
    assertEquals(6, cols1.sizeOfColArray());
    // Overlaps with 8 - 9 (before and overlap replacements required)
    CTCol col7 = createCol(6, 8);
    col7.setWidth(17.0);
    helper.addCleanColIntoCols(cols1, col7);
    assertEquals(8, cols1.sizeOfColArray());
    // Overlaps with 13 - 16750 (before, overlap and after replacements required)
    helper.addCleanColIntoCols(cols1, createCol(20, 30));
    assertEquals(10, cols1.sizeOfColArray());
    // Overlaps with 20 - 30 (before, overlap and after replacements required)
    helper.addCleanColIntoCols(cols1, createCol(25, 27));
    // TODO - assert something interesting
    assertEquals(12, cols1.sizeOfColArray());
    assertEquals(1, cols1.getColArray(0).getMin());
    assertEquals(16750, cols1.getColArray(11).getMax());
}
Also used : CTCols(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols) CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol) Test(org.junit.Test)

Example 7 with CTCol

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol in project poi by apache.

the class TestColumnHelper method testCloneCol.

@Test
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);
}
Also used : CTCols(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols) CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol) Test(org.junit.Test)

Example 8 with CTCol

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol in project poi by apache.

the class TestColumnHelper method createCol.

private static CTCol createCol(int min, int max) {
    CTCol col = CTCol.Factory.newInstance();
    col.setMin(min);
    col.setMax(max);
    return col;
}
Also used : CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Example 9 with CTCol

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol in project poi by apache.

the class ColumnHelper method cloneCol.

public CTCol cloneCol(CTCols cols, CTCol col) {
    CTCol newCol = cols.addNewCol();
    newCol.setMin(col.getMin());
    newCol.setMax(col.getMax());
    setColumnAttributes(col, newCol);
    return newCol;
}
Also used : CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Example 10 with CTCol

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol in project poi by apache.

the class ColumnHelper method setColDefaultStyle.

public void setColDefaultStyle(long index, int styleId) {
    CTCol col = getOrCreateColumn1Based(index + 1, true);
    col.setStyle(styleId);
}
Also used : CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Aggregations

CTCol (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)38 Test (org.junit.Test)19 CTCols (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols)18 CTWorksheet (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet)7 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)5 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)3 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 StylesTable (org.apache.poi.xssf.model.StylesTable)1 XSSFCellStyle (org.apache.poi.xssf.usermodel.XSSFCellStyle)1 ColumnHelper (org.apache.poi.xssf.usermodel.helpers.ColumnHelper)1 CTXf (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf)1