Better Excel operation library than npoi -- epplus

Source: Internet
Author: User

When it comes to reading and writing excel through pure. net, the first thing that comes to mind is the well-known npoi. Even Microsoft's official msdn has a dedicated article to introduce its usage. Today, I used the Excel export function in a project and tried it out specially. Although it is powerful enough, it is not easy to use. Probably because of its origins and Java's poi, most of the APIS still have a strong Java flavor. For example, to write data to a cell, createrow () must be created before createcell () can be written. Statements like cells [rowindex, colindex] = value cannot be used in one step.

As a result, I searched the internet. Are you still using npoi in the article "using Excel? Coming soon, linqtoexcel found another library: linqtoexcel. This library can quickly convert the LINQ query results to the Excel format, which is a bit similar to the doddlereport library I have previously introduced. However, it is also limited to this. The complex functions cannot be done, and in most cases cannot meet business needs.

Finally, I found a very powerful library-epplus, which basically has all the functions and friendly APIs. The following is a simple example:

???? Using (var p = newexcelpackage ())
???? {
???????? VaR sheet = P. Workbook. worksheets. Add ("My sheet ");

???????? // The initial index of cells is 1.
???????? Sheet. cells [1, 1]. value = 0;
???????? Sheet. cells [2, 1]. value = 1;
???????? Sheet. cells [3, 1]. value = 2;
???????? Sheet. cells [4, 1]. value = 3;

???????? P. saveas (newfileinfo (@ "R: \ output.xlsx "));
????}

I feel much better than npoi. The effect is as follows:

????

This example is relatively simple, more complex example can refer to this article: http://zeeshanumardotnet.blogspot.com/2010/08/creating-advanced-excel-2007-reports-on.html (need FQ ). Or its official help documentation: http://epplus.codeplex.com/wikipage? Title = FAQ & referringtitle = documentation

Finally, I would like to mention some shortcomings of this library-it only supports the XLSX format and does not support the Excel format of office2003, but it is not a problem now.

Better Excel operation library than npoi -- epplus

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.