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

void jxl::write::biff::WritableSheetImpl::insertRow ( int  row  )  [inline]

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

Parameters:
row the row to insert

Implements jxl::write::WritableSheet.

Definition at line 616 of file WritableSheetImpl.java.

References conditionalFormats, dataValidation, jxl::write::biff::CellValue::getCellFeatures(), jxl::biff::BaseCellFeatures::getDVParser(), jxl::WorkbookSettings::getFormulaAdjust(), hyperlinks, jxl::write::biff::RowRecord::incrementRow(), jxl::biff::ConditionalFormat::insertRow(), jxl::write::biff::MergedCells::insertRow(), jxl::biff::DVParser::insertRow(), jxl::biff::DataValidation::insertRow(), jxl::write::biff::HyperlinkRecord::insertRow(), mergedCells, numRows, rowBreaks, rowGrowSize, jxl::write::biff::WritableWorkbookImpl::rowInserted(), rows, validatedCells, workbook, and workbookSettings.

  {
    if (row < 0 || row >= numRows)
    {
      return;
    }

    // Create a new array to hold the new rows.  Grow it if need be
    RowRecord[] oldRows = rows;

    if (numRows == rows.length)
    {
      rows = new RowRecord[oldRows.length + rowGrowSize];
    }
    else
    {
      rows = new RowRecord[oldRows.length];
    }

    // Copy in everything up to the new row
    System.arraycopy(oldRows, 0, rows, 0, row);
    
    // Copy in the remaining rows
    System.arraycopy(oldRows, row, rows, row+1, numRows - row);

    // Increment all the internal row number by one
    for (int i = row+1; i <= numRows; i++)
    {
      if (rows[i] != null)
      {
        rows[i].incrementRow();
      }
    }

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

    // Adjust any data validations
    if (dataValidation != null)
    {
      dataValidation.insertRow(row);
    }

    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().insertRow(row);
        }
      }
    }

    // Adjust any merged cells
    mergedCells.insertRow(row);

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

      newRowBreaks.add(new Integer(val));
    }
    rowBreaks = newRowBreaks;

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

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

    // Adjust the maximum row record
    numRows++;
  }


Generated by  Doxygen 1.6.0   Back to index