A simple CSV or XLSX data sheet reader. It doesn't allocate memory for the whole input file (or stream) but reads rows and cells on demand.
Example:
var book = new Book();
var visibleRows = 0;
var invisibleRows = 0;
foreach (var sheet in book.EnumerateSheets(@"c:\path\blah.xlsx")) // or .csv
{
Console.WriteLine(sheet + " (visible:" + sheet.IsVisible + ")");
foreach (var row in sheet.EnumerateRows())
{
if (!row.IsVisible)
{
invisibleRows++;
continue;
}
visibleRows++;
Console.WriteLine(string.Join("\t", row.EnumerateCells()));
}
}
Console.WriteLine("Visible rows:" + visibleRows);
Console.WriteLine("Invisible rows:" + invisibleRows);
The code is also available as a single .cs file: SheetReader.cs
There's also a read-only WPF control that allows to see what's been read by the SheetReader:
Supports keyboard navigation, selection and focus (mouse & keyboard):
Also supports column resizing (by mouse or programmatically. Can be programmatically customized to use different styles (color, alignement, etc.):