Skip to content

A simple CSV or XLSX data sheet reader, and a WPF Sheet Control to display the read book.

License

Notifications You must be signed in to change notification settings

smourier/SheetReader

Repository files navigation

SheetReader

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:

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

About

A simple CSV or XLSX data sheet reader, and a WPF Sheet Control to display the read book.

Topics

Resources

License

Stars

Watchers

Forks

Languages