Logo Search packages:      
Sourcecode: jexcelapi version File versions  Download package

void jxl::write::biff::WritableSheetImpl::insertColumn ( int  col  )  [inline]

Inserts a blank column into this spreadsheet. If the column is out of range of the columns in the sheet, then no action is taken

Parameters:
col the column to insert

Implements jxl::write::WritableSheet.

Definition at line 719 of file WritableSheetImpl.java.

References autosizedColumns, columnBreaks, columnFormats, jxl::write::biff::WritableWorkbookImpl::columnInserted(), conditionalFormats, dataValidation, jxl::write::biff::CellValue::getCellFeatures(), jxl::write::biff::ColumnInfoRecord::getColumn(), jxl::biff::BaseCellFeatures::getDVParser(), jxl::WorkbookSettings::getFormulaAdjust(), hyperlinks, jxl::write::biff::ColumnInfoRecord::incrementColumn(), jxl::biff::ConditionalFormat::insertColumn(), jxl::write::biff::MergedCells::insertColumn(), jxl::biff::DVParser::insertColumn(), jxl::biff::DataValidation::insertColumn(), jxl::write::biff::HyperlinkRecord::insertColumn(), jxl::write::biff::RowRecord::insertColumn(), mergedCells, numColumns, numRows, rows, validatedCells, workbook, and workbookSettings.

  {
    if (col < 0 || col >= numColumns)
    {
      return;
    }

    // Iterate through all the row records adding in the column
    for (int i = 0 ; i < numRows ; i++)
    {
      if (rows[i] != null)
      {
        rows[i].insertColumn(col);
      }
    }

    // Adjust any hyperlinks
    HyperlinkRecord hr = null;
    Iterator i = hyperlinks.iterator();
    while (i.hasNext())
    {
      hr = (HyperlinkRecord) i.next();
      hr.insertColumn(col);
    }

    // Iterate through the column views, incrementing the column number
    i = columnFormats.iterator();
    while (i.hasNext())
    {
      ColumnInfoRecord cir = (ColumnInfoRecord) i.next();

      if (cir.getColumn() >= col)
      {
        cir.incrementColumn();
      }
    }

    // Iterate through the autosized columns, incrementing the column number
    if (autosizedColumns.size() > 0)
    {
      TreeSet newAutosized = new TreeSet();
      i = autosizedColumns.iterator();
      while (i.hasNext())
      {
        Integer colnumber = (Integer) i.next();

        if (colnumber.intValue() >= col)
        {
          newAutosized.add(new Integer(colnumber.intValue() + 1));
        }
        else
        {
          newAutosized.add(colnumber);
        }
      }
      autosizedColumns = newAutosized;
    }

    // Handle any data validations
    if (dataValidation != null)
    {
      dataValidation.insertColumn(col);
    }

    if (validatedCells != null && validatedCells.size() > 0)
    {
      for (Iterator vci = validatedCells.iterator(); vci.hasNext();)
      {
        CellValue cv = (CellValue) vci.next();
        CellFeatures cf = cv.getCellFeatures();
        if (cf.getDVParser() != null)
        {
          cf.getDVParser().insertColumn(col);
        }
      }
    }

    // Adjust any merged cells
    mergedCells.insertColumn(col);

    // Adjust any page breaks
    ArrayList newColumnBreaks = new ArrayList();
    Iterator ri = columnBreaks.iterator();
    while (ri.hasNext())
    {
      int val = ( (Integer) ri.next()).intValue();
      if (val >= col)
      {
        val++;
      }

      newColumnBreaks.add(new Integer(val));
    }
    columnBreaks = newColumnBreaks;

    // Adjust any conditional formats
    for (Iterator cfit = conditionalFormats.iterator(); cfit.hasNext() ;)
    {
      ConditionalFormat cf = (ConditionalFormat) cfit.next();
      cf.insertColumn(col);
    }

    // Handle interested cell references on the main workbook
    if (workbookSettings.getFormulaAdjust())
    {
      workbook.columnInserted(this, col);
    }

    numColumns++;
  }


Generated by  Doxygen 1.6.0   Back to index