Skip to content
master
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Jun 5, 2017
Jun 5, 2017
Feb 17, 2021

ClosedXML.Extensions.Mvc

MVC Extensions for ClosedXML

NuGet Badge

Install via NuGet

To install ClosedXML.Extensions.Mvc for .NET Core, run the following command in the Package Manager Console

PM> Install-Package ClosedXML.Extensions.Mvc

If you're using .NET Framework, please install v0.2.2

PM> Install-Package ClosedXML.Extensions.Mvc -Version 0.2.2

Usage

In your MVC controller define an action that will generate and download your file:

private ClosedXML.Excel.XLWorkbook GenerateClosedXMLWorkbook()
{
    var wb = new ClosedXML.Excel.XLWorkbook();
    var ws = wb.AddWorksheet();
    ws.FirstCell().SetValue("Hello world!");
    ws.FirstCell().CellBelow().FormulaA1 = "RAND()";
    return wb;
}

public ActionResult Download()
{
    using (var wb = GenerateClosedXMLWorkbook())
    {
        // Add ClosedXML.Extensions in your using declarations
        
        return wb.Deliver("generatedfile.xlsx");
        
        // or specify the content type:
        return wb.Deliver("generatedFile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    }
}

About

MVC Extensions for ClosedXML

Resources

License

Releases

No releases published

Packages

No packages published

Languages