Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.ColumnInfoRecord


     * @see org.apache.poi.hssf.record.ColumnInfoRecord
     * @return record containing a ColumnInfoRecord
     */
    public static Record createColInfo()
    {
        ColumnInfoRecord retval = new ColumnInfoRecord();

        retval.setColumnWidth(( short ) 2275);
        // was:       retval.setOptions(( short ) 6);
        retval.setOptions(( short ) 2);
        retval.setXFIndex(( short ) 0x0f);
        return retval;
    }
View Full Code Here


    }


    public void setColumn(short column, Short xfIndex, Short width, Integer level, Boolean hidden, Boolean collapsed)
    {
        ColumnInfoRecord ci = null;
        int              k  = 0;

        for (k = 0; k < records.size(); k++)
        {
            ci = ( ColumnInfoRecord ) records.get(k);
            if ((ci.getFirstColumn() <= column)
                    && (column <= ci.getLastColumn()))
            {
                break;
            }
            ci = null;
        }

        if (ci != null)
        {
      boolean styleChanged = xfIndex != null && ci.getXFIndex() != xfIndex.shortValue();
            boolean widthChanged = width != null && ci.getColumnWidth() != width.shortValue();
            boolean levelChanged = level != null && ci.getOutlineLevel() != level.intValue();
            boolean hiddenChanged = hidden != null && ci.getHidden() != hidden.booleanValue();
            boolean collapsedChanged = collapsed != null && ci.getCollapsed() != collapsed.booleanValue();
            boolean columnChanged = styleChanged || widthChanged || levelChanged || hiddenChanged || collapsedChanged;
            if (!columnChanged)
            {
                // do nothing...nothing changed.
            }
            else if ((ci.getFirstColumn() == column)
                     && (ci.getLastColumn() == column))
            {                               // if its only for this cell then
                setColumnInfoFields( ci, xfIndex, width, level, hidden, collapsed );
            }
            else if ((ci.getFirstColumn() == column)
                     || (ci.getLastColumn() == column))
            {
                // okay so the width is different but the first or last column == the column we'return setting
                // we'll just divide the info and create a new one
                if (ci.getFirstColumn() == column)
                {
                    ci.setFirstColumn(( short ) (column + 1));
                }
                else
                {
                    ci.setLastColumn(( short ) (column - 1));
                }
                ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();

                nci.setFirstColumn(column);
                nci.setLastColumn(column);
                nci.setOptions(ci.getOptions());
                nci.setXFIndex(ci.getXFIndex());
                setColumnInfoFields( nci, xfIndex, width, level, hidden, collapsed );

                insertColumn(k, nci);
            }
            else
            {
                //split to 3 records
                short lastcolumn = ci.getLastColumn();
                ci.setLastColumn(( short ) (column - 1));

                ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();
                nci.setFirstColumn(column);
                nci.setLastColumn(column);
                nci.setOptions(ci.getOptions());
                nci.setXFIndex(ci.getXFIndex());
                setColumnInfoFields( nci, xfIndex, width, level, hidden, collapsed );
                insertColumn(++k, nci);

                nci = ( ColumnInfoRecord ) createColInfo();
                nci.setFirstColumn((short)(column+1));
                nci.setLastColumn(lastcolumn);
                nci.setOptions(ci.getOptions());
                nci.setXFIndex(ci.getXFIndex());
                nci.setColumnWidth(ci.getColumnWidth());
                insertColumn(++k, nci);
            }
        }
        else
        {

            // okay so there ISN'T a column info record that cover's this column so lets create one!
            ColumnInfoRecord nci = ( ColumnInfoRecord ) createColInfo();

            nci.setFirstColumn(column);
            nci.setLastColumn(column);
            setColumnInfoFields( nci, xfIndex, width, level, hidden, collapsed );
            insertColumn(k, nci);
        }
    }
View Full Code Here

  }

  public void DISBALEDtestGetCellWidth() throws Exception
  {
    Sheet sheet = Sheet.createSheet();
    ColumnInfoRecord nci = ( ColumnInfoRecord ) sheet.createColInfo();

    // Prepare test model
    nci.setFirstColumn((short)5);
    nci.setLastColumn((short)10);
    nci.setColumnWidth((short)100);
   
    Field f = null;
    f = Sheet.class.getDeclaredField("columnSizes");
    f.setAccessible(true);
    List columnSizes = new ArrayList();
View Full Code Here

        return columnInfoRecordsAggregate.serialize(0, new byte[columnInfoRecordsAggregate.getRecordSize()]);
    }

    private ColumnInfoRecord createColumn( short firstCol, short lastCol )
    {
        ColumnInfoRecord columnInfoRecord = new ColumnInfoRecord( );
        columnInfoRecord.setFirstColumn(firstCol);
        columnInfoRecord.setLastColumn(lastCol);
        return columnInfoRecord;
    }
View Full Code Here

     * @see #setColumnWidth(int, int)
     * @return column width in units of 1/256th of a character width
     */
    public int getColumnWidth(int columnIndex) {

        ColumnInfoRecord ci = _columnInfos.findColumnInfo(columnIndex);
        if (ci != null) {
            return ci.getColumnWidth();
        }
        //default column width is measured in characters
        //multiply
        return (256*defaultcolwidth.getColWidth());
    }
View Full Code Here

     * @return index of ExtendedFormatRecord associated with
     * ColumnInfoRecord that includes the column index or the
     * index of the default ExtendedFormatRecord (0xF)
     */
    public short getXFIndexForColAt(short columnIndex) {
        ColumnInfoRecord ci = _columnInfos.findColumnInfo(columnIndex);
        if (ci != null) {
            return (short)ci.getXFIndex();
        }
        return 0xF;
    }
View Full Code Here

     * @see org.apache.poi.hssf.record.ColumnInfoRecord
     * @see #setColumnHidden(int, boolean)
     * @return whether the column is hidden or not.
     */
    public boolean isColumnHidden(int columnIndex) {
        ColumnInfoRecord cir = _columnInfos.findColumnInfo(columnIndex);
        if (cir == null) {
            return false;
        }
        return cir.getHidden();
    }
View Full Code Here

  }
  public ColumnInfoRecordsAggregate(RecordStream rs) {
    this();

    boolean isInOrder = true;
    ColumnInfoRecord cirPrev = null;
    while(rs.peekNextClass() == ColumnInfoRecord.class) {
      ColumnInfoRecord cir = (ColumnInfoRecord) rs.getNext();
      records.add(cir);
      if (cirPrev != null && CIRComparator.compareColInfos(cirPrev, cir) > 0) {
        isInOrder = false;
      }
      cirPrev = cir;
View Full Code Here

   * Performs a deep clone of the record
   */
  public Object clone() {
    ColumnInfoRecordsAggregate rec = new ColumnInfoRecordsAggregate();
    for (int k = 0; k < records.size(); k++) {
      ColumnInfoRecord ci = ( ColumnInfoRecord ) records.get(k);
      rec.records.add(ci.clone());
    }
    return rec;
  }
View Full Code Here

  public void visitContainedRecords(RecordVisitor rv) {
    int nItems = records.size();
    if (nItems < 1) {
      return;
    }
    ColumnInfoRecord cirPrev = null;
    for(int i=0; i<nItems; i++) {
      ColumnInfoRecord cir = (ColumnInfoRecord)records.get(i);
      rv.visitRecord(cir);
      if (cirPrev != null && CIRComparator.compareColInfos(cirPrev, cir) > 0) {
        // Excel probably wouldn't mind, but there is much logic in this class
        // that assumes the column info records are kept in order
        throw new RuntimeException("Column info records are out of order");
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.ColumnInfoRecord

Copyright © 2018 www.massapicom. 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.