Class StreamReadOptions
Options for a forward-only StreamRows(String, StreamReadOptions) read: which worksheet to stream and whether the first read row is a header.
Inheritance
Namespace: IronXL
Assembly: IronXL.dll
Syntax
public sealed class StreamReadOptions : Object
Controlling which worksheet to read and whether its first row is a header becomes straightforward by passing a configured StreamReadOptions to a forward-only StreamRows call. This plain options record carries four settable properties: SheetIndex, SheetName, HasHeaderRow, and HeaderRowIndex. Together they let a caller target any sheet in a workbook and tell the streaming reader exactly where column names begin, without loading the entire file into memory first.
SheetIndex and SheetName select the target worksheet. When both are set, SheetName takes precedence. HasHeaderRow signals that the first read row contains column labels rather than data; HeaderRowIndex refines that further by specifying which zero-based row index holds those labels, useful when a sheet has a title block above the real column names. The default constructor StreamReadOptions() initialises all properties to their zero-value defaults, so only the properties that differ from the defaults need to be assigned before passing the object to StreamRows.
Because StreamRows is a forward-only, low-memory path through large files, StreamReadOptions is the sole configuration surface for that read mode. Keeping the options object separate from the method signature means a single configured instance can be reused across multiple files that share the same sheet layout.
using IronXL;
var opts = new StreamReadOptions
{
SheetName = "Sales",
HasHeaderRow = true,
HeaderRowIndex = 0
};
foreach (var row in WorkBook.StreamRows("large-report.xlsx", opts))
{
Console.WriteLine(row[0].StringValue);
}The IronXL getting-started guide covers installation, and the read Excel file how-to explains broader worksheet access patterns.
Constructors
StreamReadOptions()
Declaration
public StreamReadOptions()
Properties
HasHeaderRow
When true, the row at HeaderRowIndex is consumed to name columns and is not yielded; rows after it are the data rows.
Declaration
public bool HasHeaderRow { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
HeaderRowIndex
Zero-based sheet row that holds the header, when HasHeaderRow is true.
Declaration
public int HeaderRowIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
SheetIndex
Zero-based worksheet index to stream. Ignored when SheetName is set.
Declaration
public int SheetIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
SheetName
Worksheet name to stream. When non-null, takes precedence over SheetIndex.
Declaration
public string SheetName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |