Skip to content

ryanbrandt/netxlsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ryanbrandt

NetXLSX

An easier to use .NET XLSX API

Documentation

XLSXReader

Utility class for XLSX read operations

XLSXReader _reader = new XLSXReader();

GetRecords

Generic method to parse all data in an XLSX file from a given worksheet into a List of type T.

Each property within T which we wish to have automapped to the corresponding XLSX column must have an XLSXMapping attribute, specifying the associated column name and type

public class MyModel
{
    [XLSXMapping("Some Property Column", typeof(string))]
    public string SomeProperty { get; set; }

    public string SomeUnmappedProperty { get; set; }
}
...

List<MyModel> records = _reader.GetRecords<MyModel>("<path to my XLSX file>", "<sheet of interest>");

GetWorksheets

Retrieves all worksheet names in a given XLSX file

List<string> sheets = _reader.GetWorksheets("<path to my XLSX file>");

XLSXWriter

Utility class for XLSX write operations

PutRecords

Generic method to write a list of type T to a specified XLSX worksheet.

As with GetRecords, each property within T must have an XLSXMapping attribute if we wish for it to be written to a column within the spreadsheet.

public class MyModel
{
    [XLSXMapping("Some Property Column", typeof(string))]
    public string SomePropertyIWantWritten { get; set; }

    public string SomePropertyIDontWantWritten { get; set; }
}
...

_writer.PutRecords<MyModel>("<path to my XLSX File>", "<sheet of interest>");

This method will write to an existing XLSX file, if one is found at the specified path, or create a new one, if one is not found at the specified path.

By default, this method will overwrite a file completely. If you wish to append to an existing file, specify append = true

_writer.PutRecords<MyModel>("<path to my XLSX File>", "<sheet of interest>", true);

About

XLSX utilities for .NET

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages