A simple CSV, XLSX or JSON data sheet reader. In the CSV and XLSX cases, 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 reader code (not the WPF control and sample) 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.):
Also supports column sorting, by mouse double-click on column header or programmatically. Can be programmatically customized to use different comparisoo algorithms.
Also supports column moving, by mouse drag on column header or programmatically.
It can also export data back as .JSON or .CSV files with various options: