Worksheets are the individual grids contained in an Excel file. They are represented by XLSheet objects accessible through the Sheets property in the C1XLBook class. Each sheet has a name and contains a collection of rows and columns. Individual cells can be accessed using the XLSheet indexer, which takes row and column indices.
The Rows and Columns collections in the XLSheet object extend automatically when you use their indexers. For example, if you write the following code and the sheet has fewer than 1001 rows, new rows will be automatically added, and a valid row will be returned. The same applies to XLColumn and XLCell indexers. This is different from the behavior of most collection indexers in .NET, but it makes it very easy to create and populate XLSheet objects.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Dim sheet As XLSheet = C1XLBook1.Sheets(0) Dim row As XLRow = sheet.Rows(1000) |
To write code in C#
C# |
Copy Code
|
---|---|
XLSheet sheet = c1XLBook1.Sheets[0]; XLRow row = sheet.Rows[1000]; |