new 5.0 crash with BaseSheetDataModel subclass

Posted by: zenrhapsody on 8 September 2017, 2:13 pm EST

  • Posted 8 September 2017, 2:13 pm EST

    I am trying to upgrade a Spread 4 project to use Spread 5. (5.0.3503)


    I am using custom data model derived from BaseSheetDataModel.  The code worked fine in Spread 4, but crashes in Spread 5.


    The paraphrased exception message:  Invalid column.  Column must be between 0 and 37. Value was -1.


     The stack trace:


     StackTrace
       at FarPoint.Win.Spread.SheetView.GetNote(Int32 row, Int32 column)
       at FarPoint.Win.Spread.SheetView.UpdateNotes(Int32 row, Int32 column, Boolean regenerateNote)
       at FarPoint.Win.Spread.SheetView.b(ISheetDataModel A_0)
       at FarPoint.Win.Spread.SheetView.DocumentModels.set_Data(ISheetDataModel value)
       at EmpyreanApplication.YCEditGen.GetYC(YieldCurveTS yc)


     I do not use any Notes in the sheet at all. 


     In the line above the crash, I checked RowCount and ColumnCount to be 6 and 38 respectively.


     Strange thing is that I have other subclasses of BaseSheetDataModel that are working fine.  I cannot see anything siginificantly different between the different implementations of BaseSheetDataModel subclasses to explain this issue.


    Code snippets:


    SheetView sq = new SheetView();


    fp.Sheets.Add(sq);


    YCDataModel ycModel = new YCDataModel(p1, p2);


    sq.Models.Data = ycModel;  (THIS LINE THROWS THE EXCEPTION)


    class YCDataModel : BaseSheetDataModel, INameSupport, IRangeSupport, ISpreadImplicitDataSupport, ISpreadSyncCellLocations


    Method of BaseSheetDataModel overridden:


           public override int ColumnCount
           public override int RowCount
            public override void SetValue(int row, int column, object value)
             protected override void OnChanged(SheetDataModelEventArgs e)
            public override bool IsEditable(int row, int column)
            public override bool IsEmpty()
            public override bool IsRowUsed(int row)
            public override int NonEmptyColumnCount
            public override int NonEmptyRowCount
            public override int NextNonEmptyColumnInRow(int row, int column)
            public override int NextNonEmptyRow(int row)

  • Replied 8 September 2017, 2:13 pm EST

    PROBLEM FOUND


     I did put breakpoints in my code in all the override methods.


     In 4.x, NextNonEmptyColumnInRow() and NextNonEmptyRow() are not called.


    In 5.0, they are called before the exception.


    I had a bug in NextNonEmptyColumnInRow() that returned 38 (invalid for ColumnCount==38) instead of -1 for an input column of 37


     Sorry for the confusion.


     


     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels