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

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

Removes a row from this spreadsheet. If the row is out of range of the columns in the sheet, then no action is taken

Parameters:
row the row to remove

Implements jxl::write::WritableSheet.

Definition at line 984 of file WritableSheetImpl.java.

References conditionalFormats, dataValidation, jxl::write::biff::RowRecord::decrementRow(), jxl::write::biff::CellValue::getCellFeatures(), jxl::biff::BaseCellFeatures::getDVParser(), jxl::WorkbookSettings::getFormulaAdjust(), jxl::write::biff::HyperlinkRecord::getLastRow(), jxl::write::biff::HyperlinkRecord::getRow(), hyperlinks, mergedCells, numRows, jxl::biff::ConditionalFormat::removeRow(), jxl::write::biff::MergedCells::removeRow(), jxl::biff::DVParser::removeRow(), jxl::biff::DataValidation::removeRow(), jxl::write::biff::HyperlinkRecord::removeRow(), rowBreaks, jxl::write::biff::WritableWorkbookImpl::rowRemoved(), rows, validatedCells, workbook, and workbookSettings.

  {
    if (row < 0 || row >= numRows)
    {
      // Call rowRemoved anyway, to adjust the named cells
      if (workbookSettings.getFormulaAdjust())
      {
        workbook.rowRemoved(this, row);
      }

      return;
    }

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

    rows = new RowRecord[oldRows.length];

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

    // Decrement all the internal row numbers by one
    for (int i = row; i < numRows; i++)
    {
      if (rows[i] != null)
      {
        rows[i].decrementRow();
      }
    }

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

      if (hr.getRow()      == row &&
          hr.getLastRow()  == row)
      {
        // The row with the hyperlink on has been removed, so get
        // rid of it from the list
        i.remove();
      }
      else
      {
        hr.removeRow(row);
      }
    }

    // Adjust any data validations
    if (dataValidation != null)
    {
      dataValidation.removeRow(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().removeRow(row);
        }
      }
    }

    // Adjust any merged cells
    mergedCells.removeRow(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)
      {
        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.removeRow(row);
    }

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

    // Adjust any drawings
    /*
    if (drawings != null)
    {
      for (Iterator drawingIt = drawings.iterator() ; drawingIt.hasNext() ; )
      {
        DrawingGroupObject dgo = (DrawingGroupObject) drawingIt.next();
        dgo.removeRow(row);
      }
    }
    */

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


Generated by  Doxygen 1.6.0   Back to index