CellRange and GetSelections

Posted by: r3dh2t on 8 September 2017, 1:47 pm EST

  • Posted 8 September 2017, 1:47 pm EST

    Greetings, 

    I currently am experimenting with GetSelection and CellRanges in C#.  I want to be able to take the CellRange object, and be able to do some sort of foreach loop through it.  Is this possible?  Currently the only way I can loop through to get each individual cell is this:

     

    FarPoint.Win.Spread.Model.CellRange[] cr;
                cr = spdSht.Sheets[0].GetSelections();
                for (int i = 0; i < cr.Count(); i++)
                    for (int j = cr[ i].Row; j < cr[ i].Row + cr[ i].RowCount; j++)
                        for (int k = cr[ i].Column; k < cr[ i].Column + cr[ i].ColumnCount; k++)
                            DoSomethingOn(spdSht.Sheets[0].Cells[j, k]);

    It seems like my solution is clunky.  I am hoping there is some sort of better way.  E.g. a Cellrange returns a collection of cells I can foreach loop through.   Any guidance would be greatly appreciated!

     Thanks,

    - b

  • Replied 8 September 2017, 1:47 pm EST

    Hello,


    There is not any enumerators on the CellRange object. So the code you have is the only way to get all the cells.

Need extra support?

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

Learn More

Forum Channels