This project has moved and is read-only. For the latest updates, please go here.

Exposing RangeCollection Class

Dec 15, 2010 at 7:46 AM
Edited Dec 15, 2010 at 9:54 AM

Hi,

I was just wondering what's the reason for not exposing the RangeCollection Class?

and ExcelCell class??

Also, how would you go about getting the number of record rows in the worksheet if the RangeCollection class isn't exposed?

Thanks.

Michael T.

Dec 15, 2010 at 3:19 PM

Hi,

The Rangecollection is the store for all Rows, Columns and cells and is indexed by the internal RangeID. The range ID is a long looking like this ...

((ulong)SheetID) + (((ulong)col) << 15) + (((ulong)row) << 29);

That not very user friendly, so I keep it internal.

The ExcelCell class is  the internal representation for a cell and it could be public, but i did not want to have two interfaces for cells when I added the ExcelRange class so I set it internal as well as the Cell method of the ExcelWorksheet class.

To get the number of cells in the RangeCollection (I guess you mean the _cells variable), you would have to count the cells in the worksheet using a Linq query. Not very efficient, but if you have the need for it, it would be easy to add a CellsCount property to the worksheet.

Jan

 

Dec 16, 2010 at 5:54 AM
Edited Dec 16, 2010 at 5:55 AM

Yes I see what you mean now, after having looked at it again.

The main reason why i asked was because, i wanted to know how many data row available.

I've got around this by only exposing a property within the ExcelWorksheet.

public int RowCount { get { return _rows.Count; } }

and

public int ColumnCount { get { return _columns.Count; } }

However, sometime in the future, i feel that there will be a need to expose the worksheet rows and columns.

Thanks again.

Michael T.

Dec 16, 2010 at 7:19 PM

You can also use the Worksheet.Dimensions property to get the size of the worksheet, if you dont need the the physical number of rows / columns or cells.