Search in sources :

Example 16 with CTCol

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

the class ColumnHelper method setColWidth.

public void setColWidth(long index, double width) {
    CTCol col = getOrCreateColumn1Based(index + 1, true);
    col.setWidth(width);
}
Also used : CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Example 17 with CTCol

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

the class ColumnHelper method setColHidden.

public void setColHidden(long index, boolean hidden) {
    CTCol col = getOrCreateColumn1Based(index + 1, true);
    col.setHidden(hidden);
}
Also used : CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Example 18 with CTCol

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

the class ColumnHelper method getColumn1Based.

/**
     * Returns the Column at the given 1 based index.
     * POI default is 0 based, but the file stores
     *  as 1 based.
     */
public CTCol getColumn1Based(long index1, boolean splitColumns) {
    CTCols cols = worksheet.getColsArray(0);
    // Fetching the array is quicker than working on the new style
    //  list, assuming we need to read many of them (which we often do),
    //  and assuming we're not making many changes (which we're not)
    CTCol[] colArray = cols.getColArray();
    for (CTCol col : colArray) {
        long colMin = col.getMin();
        long colMax = col.getMax();
        if (colMin <= index1 && colMax >= index1) {
            if (splitColumns) {
                if (colMin < index1) {
                    insertCol(cols, colMin, (index1 - 1), new CTCol[] { col });
                }
                if (colMax > index1) {
                    insertCol(cols, (index1 + 1), colMax, new CTCol[] { col });
                }
                col.setMin(index1);
                col.setMax(index1);
            }
            return col;
        }
    }
    return null;
}
Also used : CTCols(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols) CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Example 19 with CTCol

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

the class ColumnHelper method cloneCol.

private CTCol cloneCol(final CTCols cols, final CTCol col, final long[] newRange) {
    CTCol cloneCol = cloneCol(cols, col);
    cloneCol.setMin(newRange[0]);
    cloneCol.setMax(newRange[1]);
    return cloneCol;
}
Also used : CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Example 20 with CTCol

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

the class ColumnHelper method setColBestFit.

public void setColBestFit(long index, boolean bestFit) {
    CTCol col = getOrCreateColumn1Based(index + 1, false);
    col.setBestFit(bestFit);
}
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