the problem seems to be something else. I do not understand why the following happens (seems like a very simple and straight forward code):
With fpSpread.Sheets(0)
.Rows.Count = ViewState("AnswerCount")
.PageSize = ViewState("AnswerCount")
.Cells(row, 0, .PageSize - 1, .ColumnCount - 1).CellType = generalDataCell
.Cells(row, 0, .PageSize - 1, .ColumnCount - 1).HorizontalAlign = HorizontalAlign.Center
End With
Immediate window results on the first .cells line:
?fpSpread.Sheets(0).Rows.Count
689
?fpSpread.Sheets(0).PageSize
689
?row
2
Exception on the first .cells line:
System.IndexOutOfRangeException: Invalid row index: 2 (must be between -1 and 1).