@@ -62,15 +62,19 @@ private class BlankCellSheetGroup
6262 private int _firstColumnIndex ;
6363 private int _lastColumnIndex ;
6464 private BlankCellRectangleGroup _currentRectangleGroup ;
65+ private int _lastDefinedRow ;
6566
66- public BlankCellSheetGroup ( )
67+ public BlankCellSheetGroup ( int lastDefinedRow )
6768 {
6869 _rectangleGroups = [ ] ;
6970 _currentRowIndex = - 1 ;
71+ _lastDefinedRow = lastDefinedRow ;
7072 }
7173
7274 public void AddCell ( int rowIndex , int columnIndex )
7375 {
76+ if ( rowIndex > _lastDefinedRow )
77+ return ;
7478 if ( _currentRowIndex == - 1 )
7579 {
7680 _currentRowIndex = rowIndex ;
@@ -107,6 +111,8 @@ public void AddCell(int rowIndex, int columnIndex)
107111
108112 public bool ContainsCell ( int rowIndex , int columnIndex )
109113 {
114+ if ( rowIndex > _lastDefinedRow )
115+ return true ;
110116 for ( int i = _rectangleGroups . Count - 1 ; i >= 0 ; i -- )
111117 {
112118 BlankCellRectangleGroup bcrg = ( BlankCellRectangleGroup ) _rectangleGroups [ i ] ;
@@ -203,20 +209,20 @@ public FormulaUsedBlankCellSet()
203209 _sheetGroupsByBookSheet = new Hashtable ( ) ;
204210 }
205211
206- public void AddCell ( int bookIndex , int sheetIndex , int rowIndex , int columnIndex )
212+ public void AddCell ( IEvaluationWorkbook evalWorkbook , int bookIndex , int sheetIndex , int rowIndex , int columnIndex )
207213 {
208- BlankCellSheetGroup sbcg = GetSheetGroup ( bookIndex , sheetIndex ) ;
214+ BlankCellSheetGroup sbcg = GetSheetGroup ( evalWorkbook , bookIndex , sheetIndex ) ;
209215 sbcg . AddCell ( rowIndex , columnIndex ) ;
210216 }
211217
212- private BlankCellSheetGroup GetSheetGroup ( int bookIndex , int sheetIndex )
218+ private BlankCellSheetGroup GetSheetGroup ( IEvaluationWorkbook evalWorkbook , int bookIndex , int sheetIndex )
213219 {
214220 BookSheetKey key = new BookSheetKey ( bookIndex , sheetIndex ) ;
215221
216222 BlankCellSheetGroup result = ( BlankCellSheetGroup ) _sheetGroupsByBookSheet [ key ] ;
217223 if ( result == null )
218224 {
219- result = new BlankCellSheetGroup ( ) ;
225+ result = new BlankCellSheetGroup ( evalWorkbook . GetSheet ( sheetIndex ) . LastRowNum ) ;
220226 _sheetGroupsByBookSheet [ key ] = result ;
221227 }
222228 return result ;
0 commit comments