Skip to content

A simple CSV, XLSX or JSON data sheet reader, and a WPF Sheet Control to display the tabular data

License

Notifications You must be signed in to change notification settings

smourier/SheetReader

Repository files navigation

SheetReader

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:

image

Supports keyboard navigation, selection and focus (mouse & keyboard):

image

Also supports column resizing, by mouse or programmatically. Can be programmatically customized to use different styles (color, alignement, etc.):

image

Also supports column sorting, by mouse double-click on column header or programmatically. Can be programmatically customized to use different comparisoo algorithms.

image

Also supports column moving, by mouse drag on column header or programmatically.

image

It can also export data back as .JSON or .CSV files with various options:

image

About

A simple CSV, XLSX or JSON data sheet reader, and a WPF Sheet Control to display the tabular data

Topics

Resources

License

Stars

Watchers

Forks

Languages