ASP. NET MVC5 use NPOI to export Exceld and return to the browser for download. npoiexceld

Source: Internet
Author: User

ASP. NET MVC5 use NPOI to export Exceld and return to the browser for download. npoiexceld
I. What is NPOI?This project is the. NET version of the poi Java project located at http://poi.apache.org. POI is an open-source project that helps you read/write xls, doc, and pptfiles. It is widely used.2. NPOI advantagesOne. It is free to use most of the Excel functions (cell style, data format, formula, etc.) C. Supports xls, xlsx, and docx. D. Designed to be interface-oriented (look at the NPOI. SS namespace), it not only supports export, but also supports import of F .. Net 2.0 is based on xlsx and docx (although we also support. NET 4.0) G. Success stories from around the world H. A large number of basic examples. Independent from isolated storage3. How to reference NPOI in a projectYou can choose NuGet management in the project-manage the NuGet package of the solution to be introduced to the project.

Or go to the official website: http://npoi.codeplex.com/download dll (you can select. net2.0 or. net4.0 dll) and add references to the website.

Let's talk a little bit about code.

Here I wrote an Excel help class.

Namespace to be used

Using NPOI. HSSF. UserModel;

Using NPOI. XSSF. UserModel;

Using NPOI. SS. UserModel;

 

 

In the red frame, the DisPlayName attribute of the view object is obtained through reflection and then the value is bound.

 

Then the Controller calls and returns the File to the browser for download and preview. 

View is directly exported by clicking a label

 

NOPI is separated from the Excel version. The version cannot be imported without any effort

The first time I wrote a blog. Write is rough and simple. Click Submit at any time. I hope this article will help you get started with NOPI.

Thank you for your support. Just give me a compliment!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.