public void RemoveRow(RowRecord row)
        {
            int rowIndex = row.RowNumber;

            _valuesAgg.RemoveAllCellsValuesForRow(rowIndex);
            int       key = rowIndex;
            RowRecord rr  = (RowRecord)_rowRecords[key];

            _rowRecords.Remove(key);
            if (rr == null)
            {
                throw new Exception("Invalid row index (" + key + ")");
            }
            if (row != rr)
            {
                _rowRecords[key] = rr;
                throw new Exception("Attempt to remove row that does not belong to this sheet");
            }
        }
Ejemplo n.º 2
0
        public void TestRemoveNewRow_bug46312()
        {
            // To make bug occur, rowIndex needs to be >= ValueRecordsAggregate.records.length
            int rowIndex = 30;

            ValueRecordsAggregate vra = new ValueRecordsAggregate();
            try
            {
                vra.RemoveAllCellsValuesForRow(rowIndex);
            }
            catch (ArgumentException e)
            {
                if (e.Message.Equals("Specified rowIndex 30 is outside the allowable range (0..30)"))
                {
                    throw new AssertionException("Identified bug 46312");
                }
                throw e;
            }

            //if (false) { // same bug as demonstrated through usermodel API

            //    HSSFWorkbook wb = new HSSFWorkbook();
            //    HSSFSheet sheet = (HSSFSheet)wb.CreateSheet();
            //    HSSFRow row = (HSSFRow)sheet.CreateRow(rowIndex);
            //    if (false) { // must not add any cells to the new row if we want to see the bug
            //        row.CreateCell(0); // this causes ValueRecordsAggregate.records to auto-extend
            //    }
            //    try {
            //        sheet.CreateRow(rowIndex);
            //    } catch (ArgumentException e) {
            //        throw new AssertionException("Identified bug 46312");
            //    }
            //}
        }