-1

I am trying to inherit the FarPoint.Win.Spread.FpSpread class and implement IEnumerable<FarPoint.Win.Spread.Row> so that i should be able to apply linq on FarPoint spread rows or cells. I tried multiple ways but i keep getting errors:

class myspread : FarPoint.Win.Spread.FpSpread, IEnumerable<FarPoint.Win.Spread.Row>
{
    public IEnumerator<FarPoint.Win.Spread.Row> GetEnumerator()
    {
        return myspread.GetEnumerator();// Error on this line
    }

    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}

Second try:

class myspread : FarPoint.Win.Spread.Row, IEnumerable<FarPoint.Win.Spread.Row>
{
    public IEnumerator<FarPoint.Win.Spread.Row> GetEnumerator()
    {
        return myspread.GetEnumerator();// Error on this line
    }

    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}

Third try:

class myspread : FarPoint.Win.Spread.Cells, IEnumerable<FarPoint.Win.Spread.Cells>
{
    public IEnumerator<FarPoint.Win.Spread.Row> GetEnumerator()
    {
        return myspread.GetEnumerator();// Error on this line
    }

    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}

I want to be able to apply linq on a lot of objects on a FarPoint sheet

Now the above data could be in lacs - i need to do a lot of formatting on the above data and update values on some conditions. How can i achieve this?

Community
  • 1
  • 1
Expert Novice
  • 1,943
  • 4
  • 22
  • 47
  • I can't help but notice all three attempts are the same.. – Simon Whitehead Dec 03 '13 at 05:29
  • @SimonWhitehead looks slightly different to me (also completely random)... 3 different base classes, 2 different interfaces - should be more variations (which I hope will not appear in the post). – Alexei Levenkov Dec 03 '13 at 05:37
  • I think you need to first give yourself at least a *basic* understanding of what an IEnumerable really is. Thehttp://stackoverflow.com/questions/2789389/how-do-i-implement-ienumerable – Erik Kerber Dec 03 '13 at 05:43

1 Answers1

1

In all cases you indicate that the following line is generating the error:

return myspread.GetEnumerator();// Error on this line

Without knowing more about your code we can't really get to the bottom of this. It looks like you're trying to call the GetEnumerator method statically on the myspread class, which is probably not what you'd like it to do.

I assume that you want your class to provide enumeration over the rows in the active sheet. Looking at the documentation here, and specifically the docs for the Rows collection, I'll make some guesses about how it might look:

class myspread : FarPoint.Win.Spread.FpSpread,
    IEnumerable<FarPoint.Win.Spread.Row>
{
    public IEnumerable<FarPoint.Win.Spread.Row> GetEnumerator()
    {
        var rows = ActiveSheet.Rows;
        for (int i = 0; i < rows.Count; ++i)
            yield return rows.Item[i];
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}

Of course if the Rows collection implemented IEnumerable<Row> then this would be simply a matter of doing:

    public IEnumerable<FarPoint.Win.Spread.Row> GetEnumerator()
    {
        return ActiveSheet.Rows;
    }

The FarPoint documentation doesn't indicate any support for IEnumerable<Row> in the collection however.

Corey
  • 15,524
  • 2
  • 35
  • 68