Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 2.23 KB

README.md

File metadata and controls

49 lines (34 loc) · 2.23 KB

ExcelReportGenerator

This library allows you to render data to Microsoft Excel by marking Excel sheets using panels and templates. It makes it easy to connect to various data sources like IDataReader, DataSet, DataTable, IEnumerable and others and to render data from them to Excel. You can also apply aggregation, various types of grouping, formatting and so on to the data. You can include the library to your project via NuGet package.

How to use?

First of all you have to create a report template in Microsoft Excel. You need to mark up an excel sheet (or multiple sheets) using panels and templates which will be handled by the library. You can add any other formatting you want. All styles will be preserved after rendering. Your template can look like this:

Template

template

Next you need to create a report class that will supply data for this template

Code

    public class ReportSample
    {
        private readonly DataProvider _dataProvider = new DataProvider();

        public string ReportName => "Grouping with Panel Hierarchy";

        public IEnumerable<string> GetDepartments()
        {
            return GetAllEmployees().Select(e => e.DepartmentName).Distinct();
        }

        public IEnumerable<DataProvider.Result> GetDepartmentEmployees(string department)
        {
            return GetAllEmployees().Where(e => e.DepartmentName == department).ToArray();
        }

        public IEnumerable<DataProvider.Result> GetAllEmployees()
        {
            return _dataProvider.GetEmployeesAsIEnumerable().ToArray();
        }

        public string ConvertGender(string gender)
        {
            return gender == "M" ? "Male" : "Female";
        }
    }

Result

result

The detailed documentation is inside the Docs folder. For more information see also ExcelReportGenerator.Samples.