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

    <P>I am trying to upgrade a Spread 4 project to use Spread 5. (5.0.3503)</P>
    <P>I am using custom data model derived from BaseSheetDataModel.  The code worked fine in Spread 4, but crashes in Spread 5.</P>
    <P>The paraphrased exception message:  Invalid column.  Column must be between 0 and 37. Value was -1.</P>
    <P> The stack trace:</P>
    <P> StackTrace<BR>   at FarPoint.Win.Spread.SheetView.GetNote(Int32 row, Int32 column)<BR>   at FarPoint.Win.Spread.SheetView.UpdateNotes(Int32 row, Int32 column, Boolean regenerateNote)<BR>   at FarPoint.Win.Spread.SheetView.b(ISheetDataModel A_0)<BR>   at FarPoint.Win.Spread.SheetView.DocumentModels.set_Data(ISheetDataModel value)<BR>   at EmpyreanApplication.YCEditGen.GetYC(YieldCurveTS yc) </P>
    <P> I do not use any Notes in the sheet at all. </P>
    <P> In the line above the crash, I checked RowCount and ColumnCount to be 6 and 38 respectively.</P>
    <P> 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.</P>
    <P>Code snippets:</P><FONT color=#2b91af><FONT color=#2b91af><FONT color=#2b91af><FONT color=#2b91af>
    <P>SheetView </FONT></FONT><FONT color=#000000>sq = </FONT><FONT color=#0000ff><FONT color=#0000ff>new</FONT></FONT><FONT color=#000000> </FONT><FONT color=#2b91af><FONT color=#2b91af>SheetView</FONT></FONT><FONT color=#000000>();</FONT></P>
    <P>fp.Sheets.Add(sq);</P>
    <P>YCDataModel</FONT></FONT> ycModel = <FONT color=#0000ff><FONT color=#0000ff>new</FONT></FONT> <FONT color=#2b91af><FONT color=#2b91af>YCDataModel</FONT></FONT>(p1, p2);</P>
    <P>sq.Models.Data = ycModel;  (THIS LINE THROWS THE EXCEPTION)</P>
    <P><FONT color=#0000ff><FONT color=#0000ff>class</FONT></FONT> <FONT color=#2b91af><FONT color=#2b91af>YCDataModel</FONT></FONT> : <FONT color=#2b91af><FONT color=#2b91af>BaseSheetDataModel</FONT></FONT>, <FONT color=#2b91af><FONT color=#2b91af>INameSupport</FONT></FONT>, <FONT color=#2b91af><FONT color=#2b91af>IRangeSupport</FONT></FONT>, <FONT color=#2b91af><FONT color=#2b91af>ISpreadImplicitDataSupport</FONT></FONT>, <FONT color=#2b91af><FONT color=#2b91af>ISpreadSyncCellLocations</FONT></FONT></P>
    <P><FONT color=#000000>Method of BaseSheetDataModel overridden:</FONT></P>
    <P><FONT color=#2b91af><FONT color=#000000>       public override int ColumnCount<BR>       public override int RowCount<BR>        public override void SetValue(int row, int column, object value)<BR>         protected override void OnChanged(SheetDataModelEventArgs e)<BR>        public override bool IsEditable(int row, int column)<BR>        public override bool IsEmpty()<BR>        public override bool IsRowUsed(int row)<BR>        public override int NonEmptyColumnCount<BR>        public override int NonEmptyRowCount<BR>        public override int NextNonEmptyColumnInRow(int row, int column)<BR>        public override int NextNonEmptyRow(int row)<BR></FONT></P></FONT>
  • Replied 8 September 2017, 2:13 pm EST

    <P>PROBLEM FOUND</P>
    <P> I did put breakpoints in my code in all the override methods.</P>
    <P> In 4.x, NextNonEmptyColumnInRow() and NextNonEmptyRow() are not called.</P>
    <P>In 5.0, they are called before the exception.</P>
    <P>I had a bug in NextNonEmptyColumnInRow() that returned 38 (invalid for ColumnCount==38) instead of -1 for an input column of 37</P>
    <P> Sorry for the confusion.</P>
    <P> </P>
    <P> </P>
Need extra support?

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

Learn More

Forum Channels