All Projects → xyting → Npoi.extension

xyting / Npoi.extension

Licence: apache-2.0
This repo contains the extension for the NPOI, which provides IEnumerable<T> have save to and load from excel functionalities.

Projects that are alternatives of or similar to Npoi.extension

FluentExcel
Use Fluent API to configure POCO excel behaviors, and then provides IEnumerable<T> has save to and load from excel functionalities.
Stars: ✭ 73 (+8.96%)
Mutual labels:  excel, fluent
Autowrap
Wrap existing D code for use in Python, Excel, C#
Stars: ✭ 64 (-4.48%)
Mutual labels:  excel
Openvasreporting
OpenVAS Reporting: Convert OpenVAS XML report files to reports
Stars: ✭ 42 (-37.31%)
Mutual labels:  excel
Zerocell
Simple, efficient Excel to POJO library for Java
Stars: ✭ 53 (-20.9%)
Mutual labels:  excel
Excel2json
把Excel表转换成json对象,并保存到一个文本文件中。
Stars: ✭ 1,023 (+1426.87%)
Mutual labels:  excel
Ngx Excel Export
Angular6 application with export data to excel file functionality.
Stars: ✭ 58 (-13.43%)
Mutual labels:  excel
Fliplog
fluent logging with verbose insight, colors, tables, emoji, filtering, spinners, progress bars, timestamps, capturing, stack traces, tracking, presets, & more...
Stars: ✭ 41 (-38.81%)
Mutual labels:  fluent
Files
A modern file manager that pushes the boundaries of the platform.
Stars: ✭ 15,198 (+22583.58%)
Mutual labels:  fluent
Firetable
Excel/Google Sheets like UI for Firebase/Firestore. No more admin portals!
Stars: ✭ 1,115 (+1564.18%)
Mutual labels:  excel
Regex Builder
Write regular expressions in pure Java
Stars: ✭ 50 (-25.37%)
Mutual labels:  fluent
Tablereport
A python library for making table report.
Stars: ✭ 51 (-23.88%)
Mutual labels:  excel
Django Rest Pandas
📊📈 Serves up Pandas dataframes via the Django REST Framework for use in client-side (i.e. d3.js) visualizations and offline analysis (e.g. Excel)
Stars: ✭ 1,030 (+1437.31%)
Mutual labels:  excel
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (-8.96%)
Mutual labels:  excel
Excellentexport
Javascript export to Excel
Stars: ✭ 1,018 (+1419.4%)
Mutual labels:  excel
Expss
expss: Tables and Labels in R
Stars: ✭ 65 (-2.99%)
Mutual labels:  excel
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+1404.48%)
Mutual labels:  excel
Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (-23.88%)
Mutual labels:  fluent
Excelreaders.jl
ExcelReaders is a package that provides functionality to read Excel files.
Stars: ✭ 55 (-17.91%)
Mutual labels:  excel
Excelize
Golang library for reading and writing Microsoft Excel™ (XLSX) files.
Stars: ✭ 10,286 (+15252.24%)
Mutual labels:  excel
React Uwp
📱⌨ React Components that Implement Microsoft's UWP Design & Fluent Design.
Stars: ✭ 1,145 (+1608.96%)
Mutual labels:  fluent

The extensions for the NPOI, which provides IEnumerable<T> have save to and load from excel functionalities.

IMPORTAMT

  1. The future features will be support by FluentExcel, and will only support Fluent API.
  2. All the issues found in this repo will be and only be fixed by FluentExcel, so, please update your code to use FluentExcel.

Features

  • [x] Decouple the configuration from the POCO model by using fluent api.
  • [x] Support attributes based configurations.
  • [x] Support none configuration POCO, so that if English is your mother langurage, none any more configurations;

The first two features will be very useful for English not their mother language developers.

Overview

NPOI.Extension demo

Get Started

The following demo codes come from sample, download and run it for more information.

Using Package Manager Console to install NPOI.Extension

    PM> Install-Package NPOI.Extension

Reference NPOI.Extension in code

    using NPOI.Extension;

Configure model's excel behaviors

We can use fluent api or attributes to configure the model excel behaviors. If both had been used, fluent configurations will has the Hight Priority

1. Use Fluent Api

        public class Report {
            public string City { get; set; }
            public string Building { get; set; }
            public DateTime HandleTime { get; set; }
            public string Broker { get; set; }
            public string Customer { get; set; }
            public string Room { get; set; }
            public decimal Brokerage { get; set; }
            public decimal Profits { get; set; }
        }

        /// <summary>
        /// Use fluent configuration api. (doesn't poison your POCO)
        /// </summary>
        static void FluentConfiguration() 
        {
            var fc = Excel.Setting.For<Report>();

            fc.HasStatistics("合计", "SUM", 6, 7)
              .HasFilter(firstColumn: 0, lastColumn: 2, firstRow: 0)
              .HasFreeze(columnSplit: 2,rowSplit: 1, leftMostColumn: 2, topMostRow: 1);

            fc.Property(r => r.City)
              .HasExcelIndex(0)
              .HasExcelTitle("城市")
              .IsMergeEnabled();

            fc.Property(r => r.Building)
              .HasExcelIndex(1)
              .HasExcelTitle("楼盘")
              .IsMergeEnabled();

            fc.Property(r => r.HandleTime)
              .HasExcelIndex(2)
              .HasExcelTitle("成交时间")
              .HasDataFormatter("yyyy-MM-dd HH:mm:ss");
            
            fc.Property(r => r.Broker)
              .HasExcelIndex(3)
              .HasExcelTitle("经纪人");
            
            fc.Property(r => r.Customer)
              .HasExcelIndex(4)
              .HasExcelTitle("客户");

            fc.Property(r => r.Room)
              .HasExcelIndex(5)
              .HasExcelTitle("房源");

            fc.Property(r => r.Brokerage)
              .HasExcelIndex(6)
              .HasExcelTitle("佣金(元)");

            fc.Property(r => r.Profits)
              .HasExcelIndex(7)
              .HasExcelTitle("收益(元)");
        }

2. Use attributes

    [Statistics(Name = "合计", Formula = "SUM", Columns = new[] { 6, 7 })]
    [Filter(FirstCol = 0, FirstRow = 0, LastCol = 2)]
    [Freeze(ColSplit = 2, RowSplit = 1, LeftMostColumn = 2, TopRow = 1)]
    public class Report {
        [Column(Index = 0, Title = "城市", AllowMerge = true)]
        public string City { get; set; }
        [Column(Index = 1, Title = "楼盘", AllowMerge = true)]
        public string Building { get; set; }
        [Column(Index = 2, Title = "成交时间", Formatter = "yyyy-MM-dd HH:mm:ss")]
        public DateTime HandleTime { get; set; }
        [Column(Index = 3, Title = "经纪人")]
        public string Broker { get; set; }
        [Column(Index = 4, Title = "客户")]
        public string Customer { get; set; }
        [Column(Index = 5, Title = "房源")]
        public string Room { get; set; }
        [Column(Index = 6, Title = "佣金(元)")]
        public decimal Brokerage { get; set; }
        [Column(Index = 7, Title = "收益(元)")]
        public decimal Profits { get; set; }
    }

Export POCO to excel & Load IEnumerable<T> from excel.

using System;
using NPOI.Extension;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            // global call this
            FluentConfiguration();

            var len = 10;
            var reports = new Report[len];
            for (int i = 0; i < len; i++)
            {
                reports[i] = new Report
                {
                    City = "ningbo",
                    Building = "世茂首府",
                    HandleTime = new DateTime(2015, 11, 23),
                    Broker = "rigofunc 18957139**7",
                    Customer = "rigofunc 18957139**7",
                    Room = "2#1703",
                    Brokerage = 125M,
                    Profits = 25m
                };
            }

            var excelFile = @"/Users/rigofunc/Documents/sample.xlsx";

            // save to excel file
            reports.ToExcel(excelFile);

            // load from excel
            var loadFromExcel = Excel.Load<Report>(excelFile);
        }

        /// <summary>
        /// Use fluent configuration api. (doesn't poison your POCO)
        /// </summary>
        static void FluentConfiguration() 
        {
            var fc = Excel.Setting.For<Report>();

            fc.HasStatistics("合计", "SUM", 6, 7)
              .HasFilter(firstColumn: 0, lastColumn: 2, firstRow: 0)
              .HasFreeze(columnSplit: 2,rowSplit: 1, leftMostColumn: 2, topMostRow: 1);

            fc.Property(r => r.City)
              .HasExcelIndex(0)
              .HasExcelTitle("城市")
              .IsMergeEnabled();

            fc.Property(r => r.Building)
              .HasExcelIndex(1)
              .HasExcelTitle("楼盘")
              .IsMergeEnabled();

            fc.Property(r => r.HandleTime)
              .HasExcelIndex(2)
              .HasExcelTitle("成交时间")
              .HasDataFormatter("yyyy-MM-dd");
            
            fc.Property(r => r.Broker)
              .HasExcelIndex(3)
              .HasExcelTitle("经纪人");
            
            fc.Property(r => r.Customer)
              .HasExcelIndex(4)
              .HasExcelTitle("客户");

            fc.Property(r => r.Room)
              .HasExcelIndex(5)
              .HasExcelTitle("房源");

            fc.Property(r => r.Brokerage)
              .HasExcelIndex(6)
              .HasExcelTitle("佣金(元)");

            fc.Property(r => r.Profits)
              .HasExcelIndex(7)
              .HasExcelTitle("收益(元)");
        }
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].