天天看点

NPOI读写Excel

1、整个excel表格叫做工作表:workbook(工作薄),包含的叫页(工作表):sheet;行:row;单元格cell。

2、npoi是poi的c#版本,npoi的行和列的index都是从0开始

3、poi读取excel有两种格式一个是hssf,另一个是xssf。 hssf和xssf的区别如下: 

hssf is the poi project's pure java implementation of the excel '97(-2007) file format. 

xssf is the poi project's pure java implementation of the excel 2007 ooxml (.xlsx) file format. 

即:hssf适用2007以前的版本,xssf适用2007版本及其以上的。

下面是用npoi读写excel的例子:excelhelper封装的功能主要是把datatable中数据写入到excel中,或者是从excel读取数据到一个datatable中。

 excelhelper类:

NPOI读写Excel
NPOI读写Excel

测试代码:

NPOI读写Excel

 view code

签于这篇文章阅读量较高,更新一下我使用aspose.cells的另一个版本:

ps:aspose是要收费的

NPOI读写Excel
NPOI读写Excel

参考:

<a href="http://www.cnblogs.com/erik_xu/archive/2012/06/08/2541957.html">http://www.cnblogs.com/erik_xu/archive/2012/06/08/2541957.html</a>

<a href="http://www.cnblogs.com/linzheng/archive/2010/12/20/1912137.html">http://www.cnblogs.com/linzheng/archive/2010/12/20/1912137.html</a>

<a href="http://www.cnblogs.com/knowledgesea/archive/2012/11/16/2772547.html">http://www.cnblogs.com/knowledgesea/archive/2012/11/16/2772547.html</a>

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

http://www.cnblogs.com/luxiaoxun/p/3374992.html