-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?

3
  • I can't help but notice all three attempts are the same.. Dec 3, 2013 at 5: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). Dec 3, 2013 at 5: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 Dec 3, 2013 at 5:43

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.