精华内容
下载资源
问答
  • NPOI组件的使用和例子

    2012-05-15 08:57:08
    NPOI组件的使用和例子,导出快速,便捷
  • VS下操作后缀为xls与xlsx的Excel文件,所引用的NPOI组件集合,包括: ICSharpCode.SharpZipLib.dll; NPOI.dll; NPOI.OOXML.dll; NPOI.OpenXml4Net.dll。
  • NET使用NPOI组件将数据导出Excel
  • NPOI组件将数据导出Excel(多个工作簿) 附带提炼“内库”方法
  • 可以到此网站上去下载最新的NPOI组件版本 2、NPOI在线学习教程(中文版): http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html 感谢Tony Qu分享出NPOI组件的使用方法 3、.NET调用NPOI组件导入...

    、NPOI官方网站http://npoi.codeplex.com/

       可以到此网站上去下载最新的NPOI组件版本

    2、NPOI在线学习教程(中文版):

        http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html

       感谢Tony Qu分享出NPOI组件的使用方法

    3、.NET调用NPOI组件导入导出Excel的操作类
      此NPOI操作类的优点如下:
       (1)支持web及winform从DataTable导出到Excel; 
       (2)生成速度很快; 
       (3)准确判断数据类型,不会出现身份证转数值等问题; 
       (4)如果单页条数大于65535时会新建工作表; 
       (5)列宽自适应;

     

    NPOI操作类

    Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->  1 using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.IO;
    using System.Text;
    using NPOI;
    using NPOI.HPSF;
    using NPOI.HSSF;
    using NPOI.HSSF.UserModel;
    using NPOI.HSSF.Util;
    using NPOI.POIFS;
    using NPOI.Util;  
    namespace PMS.Common
    {
        public class NPOIHelper
        {
            /// <summary>
            /// DataTable导出到Excel文件
            /// </summary>
            /// <param name="dtSource">源DataTable</param>
            /// <param name="strHeaderText">表头文本</param>
            /// <param name="strFileName">保存位置</param>
            public static void Export(DataTable dtSource, string strHeaderText, string strFileName)
            {
                using (MemoryStream ms = Export(dtSource, strHeaderText))
                {
                    using (FileStream fs = new FileStream(strFileName, FileMode.Create, FileAccess.Write))
                    {
                        byte[] data = ms.ToArray();
                        fs.Write(data, 0, data.Length);
                        fs.Flush();
                    }
                }
            }

            /// <summary>
            /// DataTable导出到Excel的MemoryStream
            /// </summary>
            /// <param name="dtSource">源DataTable</param>
            /// <param name="strHeaderText">表头文本</param>
            public static MemoryStream Export(DataTable dtSource, string strHeaderText)
            {
                HSSFWorkbook workbook = new HSSFWorkbook();
                HSSFSheet sheet = workbook.CreateSheet();

                #region 右击文件 属性信息
                {
                    DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
                    dsi.Company = "NPOI";
                    workbook.DocumentSummaryInformation = dsi;

                    SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
                    si.Author = "文件作者信息"; //填加xls文件作者信息
                    si.ApplicationName = "创建程序信息"; //填加xls文件创建程序信息
                    si.LastAuthor = "最后保存者信息"; //填加xls文件最后保存者信息
                    si.Comments = "作者信息"; //填加xls文件作者信息
                    si.Title = "标题信息"; //填加xls文件标题信息
                    si.Subject = "主题信息";//填加文件主题信息
                    si.CreateDateTime = DateTime.Now;
                    workbook.SummaryInformation = si;
                }
                #endregion

                HSSFCellStyle dateStyle = workbook.CreateCellStyle();
                HSSFDataFormat format = workbook.CreateDataFormat();
                dateStyle.DataFormat = format.GetFormat("yyyy-mm-dd");

                //取得列宽
                int[] arrColWidth = new int[dtSource.Columns.Count];
                foreach (DataColumn item in dtSource.Columns)
                {
                    arrColWidth[item.Ordinal] = Encoding.GetEncoding(936).GetBytes(item.ColumnName.ToString()).Length;
                }
                for (int i = 0; i < dtSource.Rows.Count; i++)
                {
                    for (int j = 0; j < dtSource.Columns.Count; j++)
                    {
                        int intTemp = Encoding.GetEncoding(936).GetBytes(dtSource.Rows[i][j].ToString()).Length;
                        if (intTemp > arrColWidth[j])
                        {
                            arrColWidth[j] = intTemp;
                        }
                    }
                }
                int rowIndex = 0;
                foreach (DataRow row in dtSource.Rows)
                {
                    #region 新建表,填充表头,填充列头,样式
                    if (rowIndex == 65535 || rowIndex == 0)
                    {
                        if (rowIndex != 0)
                        {
                            sheet = workbook.CreateSheet();
                        }

                        #region 表头及样式
                        {
                            HSSFRow headerRow = sheet.CreateRow(0);
                            headerRow.HeightInPoints = 25;
                            headerRow.CreateCell(0).SetCellValue(strHeaderText);

                            HSSFCellStyle headStyle = workbook.CreateCellStyle();
                            headStyle.Alignment = CellHorizontalAlignment.CENTER;
                            HSSFFont font = workbook.CreateFont();
                            font.FontHeightInPoints = 20;
                            font.Boldweight = 700;
                            headStyle.SetFont(font);
                            headerRow.GetCell(0).CellStyle = headStyle;
                            sheet.AddMergedRegion(new Region(0, 0, 0, dtSource.Columns.Count - 1));
                            headerRow.Dispose();
                        }
                        #endregion


                        #region 列头及样式
                        {
                            HSSFRow headerRow = sheet.CreateRow(1);
                            HSSFCellStyle headStyle = workbook.CreateCellStyle();
                            headStyle.Alignment = CellHorizontalAlignment.CENTER;
                            HSSFFont font = workbook.CreateFont();
                            font.FontHeightInPoints = 10;
                            font.Boldweight = 700;
                            headStyle.SetFont(font);
                            foreach (DataColumn column in dtSource.Columns)
                            {
                                headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
                                headerRow.GetCell(column.Ordinal).CellStyle = headStyle;

                                //设置列宽
                                sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal] + 1) * 256);
                            }
                            headerRow.Dispose();
                        }
                        #endregion

                        rowIndex = 2;
                    }
                    #endregion


                    #region 填充内容
                    HSSFRow dataRow = sheet.CreateRow(rowIndex);
                    foreach (DataColumn column in dtSource.Columns)
                    {
                        HSSFCell newCell = dataRow.CreateCell(column.Ordinal);

                        string drValue = row[column].ToString();

                        switch (column.DataType.ToString())
                        {
                            case "System.String"://字符串类型
                                newCell.SetCellValue(drValue);
                                break;
                            case "System.DateTime"://日期类型
                                DateTime dateV;
                                DateTime.TryParse(drValue, out dateV);
                                newCell.SetCellValue(dateV);

                                newCell.CellStyle = dateStyle;//格式化显示
                                break;
                            case "System.Boolean"://布尔型
                                bool boolV = false;
                                bool.TryParse(drValue, out boolV);
                                newCell.SetCellValue(boolV);
                                break;
                            case "System.Int16"://整型
                            case "System.Int32":
                            case "System.Int64":
                            case "System.Byte":
                                int intV = 0;
                                int.TryParse(drValue, out intV);
                                newCell.SetCellValue(intV);
                                break;
                            case "System.Decimal"://浮点型
                            case "System.Double":
                                double doubV = 0;
                                double.TryParse(drValue, out doubV);
                                newCell.SetCellValue(doubV);
                                break;
                            case "System.DBNull"://空值处理
                                newCell.SetCellValue("");
                                break;
                            default:
                                newCell.SetCellValue("");
                                break;
                        }

                    }
                    #endregion

                    rowIndex++;
                }
                using (MemoryStream ms = new MemoryStream())
                {
                    workbook.Write(ms);
                    ms.Flush();
                    ms.Position = 0;

                    sheet.Dispose();
                    //workbook.Dispose();//一般只用写这一个就OK了,他会遍历并释放所有资源,但当前版本有问题所以只释放sheet
                    return ms;
                }
            }

            /// <summary>
            /// 用于Web导出
            /// </summary>
            /// <param name="dtSource">源DataTable</param>
            /// <param name="strHeaderText">表头文本</param>
            /// <param name="strFileName">文件名</param>
            public static void ExportByWeb(DataTable dtSource, string strHeaderText, string strFileName)
            {
                HttpContext curContext = HttpContext.Current;

                // 设置编码和附件格式
                curContext.Response.ContentType = "application/vnd.ms-excel";
                curContext.Response.ContentEncoding = Encoding.UTF8;
                curContext.Response.Charset = "";
                curContext.Response.AppendHeader("Content-Disposition",
                    "attachment;filename=" + HttpUtility.UrlEncode(strFileName, Encoding.UTF8));

                curContext.Response.BinaryWrite(Export(dtSource, strHeaderText).GetBuffer());
                curContext.Response.End();
            }

            /// <summary>读取excel
            /// 默认第一行为标头
            /// </summary>
            /// <param name="strFileName">excel文档路径</param>
            /// <returns></returns>
            public static DataTable Import(string strFileName)
            {
                DataTable dt = new DataTable();

                HSSFWorkbook hssfworkbook;
                using (FileStream file = new FileStream(strFileName, FileMode.Open, FileAccess.Read))
                {
                    hssfworkbook = new HSSFWorkbook(file);
                }
                HSSFSheet sheet = hssfworkbook.GetSheetAt(0);
                System.Collections.IEnumerator rows = sheet.GetRowEnumerator();

                HSSFRow headerRow = sheet.GetRow(0);
                int cellCount = headerRow.LastCellNum;

                for (int j = 0; j < cellCount; j++)
                {
                    HSSFCell cell = headerRow.GetCell(j);
                    dt.Columns.Add(cell.ToString());
                }

                for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
                {
                    HSSFRow row = sheet.GetRow(i);
                    DataRow dataRow = dt.NewRow();

                    for (int j = row.FirstCellNum; j < cellCount; j++)
                    {
                        if (row.GetCell(j) != null)
                            dataRow[j] = row.GetCell(j).ToString();
                    }

                    dt.Rows.Add(dataRow);
                }
                return dt;
            }
        }
    }

     

     

     

    4、NPOI操作类的调用方法
       DataTable dt_Grade = Tools.Data.GetDataTable(strSQL);
       filename += "绩效考核结果分数统计表";
       PMS.Common.NPOIHelper.ExportByWeb(dt_Grade, filename, filename+".xls");

    5、效果展示
       

    6、NPOI类库下载:http://files.cnblogs.com/dreamof/NPOIç±»åº.rar

    信息来源:http://www.cnblogs.com/yongfa365/archive/2010/05/10/NPOI-MyXls-DataTable-To-Excel-From-Excel.html

     

    查看原文:http://www.cnblogs.com/dreamof/archive/2010/06/02/1750151.html

     

    转载于:https://www.cnblogs.com/lizihong/p/4320002.html

    展开全文
  • 利用NPOI组件读写XLS文件

    千次阅读 2016-06-01 18:36:46
    利用NPOI组件读写XLS文件

    利用NPOI组件读写XLS文件

    简介:NPOI 是 POI 项目的 .NET 版本。POI是一个开源的Java读写Excel、WORD等微软OLE2组件文档的项目。

    优势:

    (一)传统操作 Excel遇到的问题:
    1、如果是 .NET,需要在服务器端装 Office,且及时更新它,以防漏洞,还需要设定权限允许 .NET访问 COM+,如果在导出过程中出问题可能导致服务器宕机。
    2、 Excel会把只包含数字的列进行类型转换,本来是文本型的, Excel会将其转成数值型的,比如编号000123会变成123。
    3、导出时,如果字段内容以“-”或“=”开头,Excel会把它当成公式进行,会报错。
    4、 Excel会根据 Excel文件前8行分析数据类型,如果正好你前8行某一列只是数字,那它会认为该列为数值型,自动将该列转变成类似1.42702 E+17格式,日期列变成包含日期和数字的。
    (二)使用 NPOI的优势
    1、您可以完全免费使用该框架
    2、包含了大部分EXCEL的特性(单元格样式、数据格式、公式等等)
    3、专业的技术支持服务(24*7全天候) (非免费)
    4、支持处理的文件格式包括xls、xlsx、doc.
    5、采用面向接口的设计架构( 可以查看 NPOI.SS的命名空间)
    6、同时支持文件的导入和导出
    7、基于.net 2.0 也支持xlsx 和 docx格式(当然也支持.net 4.0)
    8、来自全世界大量成功且真实的测试Cases
    9、大量的实例代码
    11、你不需要在服务器上安装微软的Office,可以避免版权问题。
    12、使用起来比Office PIAAPI更加方便,更人性化。
    13、你不用去花大力气维护NPOINPOI Team会不断更新、改善NPOI,绝对省成本。
    NPOI之所以强大,并不是因为它支持导出 Excel,而是因为它支持导入 Excel,并能“理解” OLE2文档结构,这也是其他一些Excel读写库比较弱的方面。通常,读入并理解结构远比导出来得复杂,因为导入你必须假设一切情况都是可能的,而生成你只要保证满足你自己需求就可以了,如果把导入需求和生成需求比做两个集合,那么生成需求通常都是导入需求的子集,这一规律不仅体现在 Excel读写库中,也体现在 pdf读写库中,目前市面上大部分的 pdf库仅支持生成,不支持导入。

    解决方案:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    using System.IO;
    
    using NPOI.HSSF.Model; // InternalWorkbook
    using NPOI.HSSF.UserModel; // HSSFWorkbook, HSSFSheet
    
    /*----------------------------------------------------------------
    // Copyright (C) 2016 公司 
    //
    // filename:Program.cs
    // fileremark:利用NPOI组件进行读写xls文件
    // author:彭振
    // time:2016-06-01 17:03:07
    //
    //----------------------------------------------------------------*/
    namespace XlsViaNpoi
    {
        public partial class Form1 : Form
        {
            HSSFWorkbook wb;
            HSSFSheet sh;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                //如果xls文件不存在则创建
                if (!File.Exists("test.xls"))
                {
                    wb = HSSFWorkbook.Create(InternalWorkbook.CreateWorkbook());
    
                    // 创建sheet
                    sh = (HSSFSheet)wb.CreateSheet("Sheet1");
                    // 3行,2列
                    for (int i = 0; i < 3; i++)
                    {
                        var r = sh.CreateRow(i);
                        for (int j = 0; j < 2; j++)
                        {
                            r.CreateCell(j);
                        }
                    }
    
                    using (var fs = new FileStream("test.xls", FileMode.Create, FileAccess.Write))
                    {
                        wb.Write(fs);
                    }
                }
    
                //从xls文件中获取sheets列表
                using (var fs = new FileStream("test.xls", FileMode.Open, FileAccess.Read))
                {
                    wb = new HSSFWorkbook(fs);
    
                    for (int i = 0; i < wb.Count; i++)
                    {
                        comboBox1.Items.Add(wb.GetSheetAt(i).SheetName);
                    }
                }
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                // 填充前清除grid
                dataGridView1.Rows.Clear();
                dataGridView1.Columns.Clear();
    
                // 获取sheet
                sh = (HSSFSheet)wb.GetSheet(comboBox1.SelectedItem.ToString());
    
                int i = 0;
                while (sh.GetRow(i) != null)
                {
                    // 添加列
                    if (dataGridView1.Columns.Count < sh.GetRow(i).Cells.Count)
                    {
                        for (int j = 0; j < sh.GetRow(i).Cells.Count; j++)
                        {
                            dataGridView1.Columns.Add("", "");
                        }
                    }
                    
                    // 添加行
                    dataGridView1.Rows.Add();
                    
                    // 写入行数值
                    for (int j = 0; j < sh.GetRow(i).Cells.Count; j++)
                    {
                        var cell = sh.GetRow(i).GetCell(j);
    
                        if (cell != null)
                        {
                            // 备注: 可以添加更多的行列类型
                            switch (cell.CellType)
                            {
                                case NPOI.SS.UserModel.CellType.Numeric:
                                    dataGridView1[j, i].Value = sh.GetRow(i).GetCell(j).NumericCellValue;
                                    break;
                                case NPOI.SS.UserModel.CellType.String:
                                    dataGridView1[j, i].Value = sh.GetRow(i).GetCell(j).StringCellValue;
                                    break;
                            }
                        }
                    }
    
                    i++;
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                {
                    if (sh.GetRow(i) == null)
                        sh.CreateRow(i);
    
                    for (int j = 0; j < dataGridView1.ColumnCount; j++)
                    {
                        if (sh.GetRow(i).GetCell(j) == null)
                            sh.GetRow(i).CreateCell(j);
    
                        if (dataGridView1[j, i].Value != null)
                        {
                            sh.GetRow(i).GetCell(j).SetCellValue(dataGridView1[j, i].Value.ToString());
                        }
                    }
                }
    
                using (var fs = new FileStream("test.xls", FileMode.Open, FileAccess.Write))
                {
                    wb.Write(fs);
                }
            }
        }
    }
    

    namespace XlsViaNpoi
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Windows Form Designer generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.components = new System.ComponentModel.Container();
                this.dataGridView1 = new System.Windows.Forms.DataGridView();
                this.comboBox1 = new System.Windows.Forms.ComboBox();
                this.label1 = new System.Windows.Forms.Label();
                this.button1 = new System.Windows.Forms.Button();
                this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
                this.button2 = new System.Windows.Forms.Button();
                ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
                this.SuspendLayout();
                // 
                // dataGridView1
                // 
                this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                this.dataGridView1.Location = new System.Drawing.Point(12, 34);
                this.dataGridView1.Name = "dataGridView1";
                this.dataGridView1.ShowCellToolTips = false;
                this.dataGridView1.Size = new System.Drawing.Size(504, 233);
                this.dataGridView1.TabIndex = 0;
                // 
                // comboBox1
                // 
                this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                this.comboBox1.FormattingEnabled = true;
                this.comboBox1.Location = new System.Drawing.Point(96, 9);
                this.comboBox1.Name = "comboBox1";
                this.comboBox1.Size = new System.Drawing.Size(130, 20);
                this.comboBox1.TabIndex = 1;
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(12, 12);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(95, 12);
                this.label1.TabIndex = 2;
                this.label1.Text = "Select a sheet:";
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(232, 7);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(75, 21);
                this.button1.TabIndex = 3;
                this.button1.Text = "Show";
                this.button1.UseVisualStyleBackColor = true;
                this.button1.Click += new System.EventHandler(this.button1_Click);
                // 
                // toolTip1
                // 
                this.toolTip1.IsBalloon = true;
                this.toolTip1.UseAnimation = false;
                this.toolTip1.UseFading = false;
                // 
                // button2
                // 
                this.button2.Location = new System.Drawing.Point(423, 7);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(93, 21);
                this.button2.TabIndex = 4;
                this.button2.Text = "Save changes";
                this.button2.UseVisualStyleBackColor = true;
                this.button2.Click += new System.EventHandler(this.button2_Click);
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(528, 278);
                this.Controls.Add(this.button2);
                this.Controls.Add(this.button1);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.comboBox1);
                this.Controls.Add(this.dataGridView1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.Load += new System.EventHandler(this.Form1_Load);
                ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            #endregion
    
            private System.Windows.Forms.DataGridView dataGridView1;
            private System.Windows.Forms.ComboBox comboBox1;
            private System.Windows.Forms.Label label1;
            private System.Windows.Forms.Button button1;
            private System.Windows.Forms.ToolTip toolTip1;
            private System.Windows.Forms.Button button2;
        }
    }
    
    


    DLL资源包:NPOI 2.2.1 binary package.zip

    利用NPOI组件读写XLS文件:利用NPOI组件读写XLS文件

    
    展开全文
  • NPOI组件扩展dll

    2018-08-22 14:41:47
    NPOI.dll,NPOI.OOXML.dll,NPOI.OpenXml4Net.dll,NPOI.OpenXmlFormats.dll
  • 基于NPOI组件的Excel导入导出 无需系统Office组件 (1)支持web及winform从DataTable导出到Excel; (2)生成速度很快; (3)准确判断数据类型,不会出现身份证转数值等问题; (4)如果单页条数大于65535时...
  • 利用NPOI组件读写XLSX文件

    千次阅读 2016-06-03 11:39:37
    利用NPOI组件读写XLSX文件 简介:NPOI 是 POI 项目的 .NET 版本。POI是一个开源的Java读写Excel、WORD等微软OLE2组件文档的项目。  NPOI操作Excel时分为.xls和.xlsx的操作,上篇文章讲述了.xls的操作,这篇文章将...
    

    利用NPOI组件读写XLSX文件

    简介:NPOI 是 POI 项目的 .NET 版本。POI是一个开源的Java读写Excel、WORD等微软OLE2组件文档的项目。

               NPOI操作Excel时分为.xls和.xlsx的操作,上篇文章讲述了.xls的操作,这篇文章将讲述.xlsx的操作

    解决方案:

    设计文件:

    namespace XlsxViaNpoi
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Windows Form Designer generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.components = new System.ComponentModel.Container();
                this.dataGridView1 = new System.Windows.Forms.DataGridView();
                this.comboBox1 = new System.Windows.Forms.ComboBox();
                this.label1 = new System.Windows.Forms.Label();
                this.button1 = new System.Windows.Forms.Button();
                this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
                this.button2 = new System.Windows.Forms.Button();
                ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
                this.SuspendLayout();
                // 
                // dataGridView1
                // 
                this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                this.dataGridView1.Location = new System.Drawing.Point(12, 37);
                this.dataGridView1.Name = "dataGridView1";
                this.dataGridView1.ShowCellToolTips = false;
                this.dataGridView1.Size = new System.Drawing.Size(504, 252);
                this.dataGridView1.TabIndex = 0;
                // 
                // comboBox1
                // 
                this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                this.comboBox1.FormattingEnabled = true;
                this.comboBox1.Location = new System.Drawing.Point(96, 10);
                this.comboBox1.Name = "comboBox1";
                this.comboBox1.Size = new System.Drawing.Size(130, 21);
                this.comboBox1.TabIndex = 1;
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(12, 13);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(78, 13);
                this.label1.TabIndex = 2;
                this.label1.Text = "Select a sheet:";
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(232, 8);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(75, 23);
                this.button1.TabIndex = 3;
                this.button1.Text = "Show";
                this.button1.UseVisualStyleBackColor = true;
                this.button1.Click += new System.EventHandler(this.button1_Click);
                // 
                // toolTip1
                // 
                this.toolTip1.IsBalloon = true;
                this.toolTip1.UseAnimation = false;
                this.toolTip1.UseFading = false;
                // 
                // button2
                // 
                this.button2.Location = new System.Drawing.Point(423, 8);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(93, 23);
                this.button2.TabIndex = 4;
                this.button2.Text = "Save changes";
                this.button2.UseVisualStyleBackColor = true;
                this.button2.Click += new System.EventHandler(this.button2_Click);
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(528, 301);
                this.Controls.Add(this.button2);
                this.Controls.Add(this.button1);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.comboBox1);
                this.Controls.Add(this.dataGridView1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.Load += new System.EventHandler(this.Form1_Load);
                ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            #endregion
    
            private System.Windows.Forms.DataGridView dataGridView1;
            private System.Windows.Forms.ComboBox comboBox1;
            private System.Windows.Forms.Label label1;
            private System.Windows.Forms.Button button1;
            private System.Windows.Forms.ToolTip toolTip1;
            private System.Windows.Forms.Button button2;
        }
    }
    
    

    CS文件:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    using System.IO; // File.Exists()
    
    using NPOI.XSSF.UserModel; // XSSFWorkbook, XSSFSheet
    
    /*----------------------------------------------------------------
    // Copyright (C) 2016 公司 
    //
    // filename:Program.cs
    // fileremark:利用NPOI组件进行读写xlsx文件
    // author:彭振
    // time:2016-06-01 17:23:33
    //
    //----------------------------------------------------------------*/
    namespace XlsxViaNpoi
    {
        public partial class Form1 : Form
        {
            XSSFWorkbook wb;
            XSSFSheet sh;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                //如果xls文件不存在则创建
                if (!File.Exists("test.xlsx"))
                {
                    wb = new XSSFWorkbook();
    
                    // 创建sheet
                    sh = (XSSFSheet)wb.CreateSheet("Sheet1");
                    // 3行,2列
                    for (int i = 0; i < 3; i++)
                    {
                        var r = sh.CreateRow(i);
                        for (int j = 0; j < 2; j++)
                        {
                            r.CreateCell(j);
                        }
                    }
    
                    using (var fs = new FileStream("test.xlsx", FileMode.Create, FileAccess.Write))
                    {
                        wb.Write(fs);
                    }
                }
    
                //从xls文件中获取sheets列表
                using (var fs = new FileStream("test.xlsx", FileMode.Open, FileAccess.Read))
                {
                    wb = new XSSFWorkbook(fs);
    
                    for (int i = 0; i < wb.Count; i++)
                    {
                        comboBox1.Items.Add(wb.GetSheetAt(i).SheetName);
                    }
                }
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                // 填充前清除grid
                dataGridView1.Rows.Clear();
                dataGridView1.Columns.Clear();
    
                // 获取sheet
                sh = (XSSFSheet)wb.GetSheet(comboBox1.SelectedItem.ToString());
    
                int i = 0;
                while (sh.GetRow(i) != null)
                {
                    // 添加列
                    if (dataGridView1.Columns.Count < sh.GetRow(i).Cells.Count)
                    {
                        for (int j = 0; j < sh.GetRow(i).Cells.Count; j++)
                        {
                            dataGridView1.Columns.Add("", "");
                        }
                    }
    
                    // 添加行
                    dataGridView1.Rows.Add();
    
                    // 写入行数值
                    for (int j = 0; j < sh.GetRow(i).Cells.Count; j++)
                    {
                        var cell = sh.GetRow(i).GetCell(j);
    
                        if (cell != null)
                        {
                            // 备注: 可以添加更多的行列类型
                            switch (cell.CellType)
                            {
                                case NPOI.SS.UserModel.CellType.Numeric:
                                    dataGridView1[j, i].Value = sh.GetRow(i).GetCell(j).NumericCellValue;
                                    break;
                                case NPOI.SS.UserModel.CellType.String:
                                    dataGridView1[j, i].Value = sh.GetRow(i).GetCell(j).StringCellValue;
                                    break;
                            }
                        }
                    }
    
                    i++;
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                {
                    if (sh.GetRow(i) == null)
                        sh.CreateRow(i);
    
                    for (int j = 0; j < dataGridView1.ColumnCount; j++)
                    {
                        if (sh.GetRow(i).GetCell(j) == null)
                            sh.GetRow(i).CreateCell(j);
    
                        if (dataGridView1[j, i].Value != null)
                        {
                            sh.GetRow(i).GetCell(j).SetCellValue(dataGridView1[j, i].Value.ToString());
                        }
                    }
                }
    
                using (var fs = new FileStream("test.xlsx", FileMode.Open, FileAccess.Write))
                {
                    wb.Write(fs);
                }
            }
        }
    }
    

    利用NPOI组件读写XLS文件: http://blog.csdn.net/pengzhen8805/article/details/51556880

    展开全文
  • 1、NPOI官方网站:http://npoi.codeplex.com/ 可以到此网站上去下载最新的NPOI组件版本 2、NPOI在线学习教程(中文版): http://www.cnbl
    原文地址为:
    【推荐】.NET使用NPOI组件将数据导出Excel
    

    1、NPOI官方网站http://npoi.codeplex.com/

       可以到此网站上去下载最新的NPOI组件版本

    2、NPOI在线学习教程(中文版):

        http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html

       感谢Tony Qu分享出NPOI组件的使用方法

    3、.NET调用NPOI组件导入导出Excel的操作类
      此NPOI操作类的优点如下:
       (1)支持web及winform从DataTable导出到Excel; 
       (2)生成速度很快; 
       (3)准确判断数据类型,不会出现身份证转数值等问题; 
       (4)如果单页条数大于65535时会新建工作表; 
       (5)列宽自适应;

    961ddebeb323a10fe0623af514929fc1.jpe NPOI操作类
      1  using  System;
      2  using  System.Data;
      3  using  System.Configuration;
      4  using  System.Web;
      5  using  System.Web.Security;
      6  using  System.Web.UI;
      7  using  System.Web.UI.HtmlControls;
      8  using  System.Web.UI.WebControls;
      9  using  System.Web.UI.WebControls.WebParts;
     10  using  System.IO;
     11  using  System.Text;
     12  using  NPOI;
     13  using  NPOI.HPSF;
     14  using  NPOI.HSSF;
     15  using  NPOI.HSSF.UserModel;
     16  using  NPOI.HSSF.Util;
     17  using  NPOI.POIFS;
     18  using  NPOI.Util;   
     20  namespace  PMS.Common
     21  {
     22       public   class  NPOIHelper
     23      {
     24           ///   <summary>
     25           ///  DataTable导出到Excel文件
     26           ///   </summary>
     27           ///   <param name="dtSource"> 源DataTable </param>
     28           ///   <param name="strHeaderText"> 表头文本 </param>
     29           ///   <param name="strFileName"> 保存位置 </param>
     30           public   static   void  Export(DataTable dtSource,  string  strHeaderText,  string  strFileName)
     31          {
     32               using  (MemoryStream ms  =  Export(dtSource, strHeaderText))
     33              {
     34                   using  (FileStream fs  =   new  FileStream(strFileName, FileMode.Create, FileAccess.Write))
     35                  {
     36                       byte [] data  =  ms.ToArray();
     37                      fs.Write(data,  0 , data.Length);
     38                      fs.Flush();
     39                  }
     40              }
     41          }
     42 
     43           ///   <summary>
     44           ///  DataTable导出到Excel的MemoryStream
     45           ///   </summary>
     46           ///   <param name="dtSource"> 源DataTable </param>
     47           ///   <param name="strHeaderText"> 表头文本 </param>
     48           public   static  MemoryStream Export(DataTable dtSource,  string  strHeaderText)
     49          {
     50              HSSFWorkbook workbook  =   new  HSSFWorkbook();
     51              HSSFSheet sheet  =  workbook.CreateSheet();
     52 
     53               #region  右击文件 属性信息
     54              {
     55                  DocumentSummaryInformation dsi  =  PropertySetFactory.CreateDocumentSummaryInformation();
     56                  dsi.Company  =   " NPOI " ;
     57                  workbook.DocumentSummaryInformation  =  dsi;
     58 
     59                  SummaryInformation si  =  PropertySetFactory.CreateSummaryInformation();
     60                  si.Author  =   " 文件作者信息 " // 填加xls文件作者信息
     61                  si.ApplicationName  =   " 创建程序信息 " // 填加xls文件创建程序信息
     62                  si.LastAuthor  =   " 最后保存者信息 " // 填加xls文件最后保存者信息
     63                  si.Comments  =   " 作者信息 " // 填加xls文件作者信息
     64                  si.Title  =   " 标题信息 " // 填加xls文件标题信息
     65                  si.Subject  =   " 主题信息 " ; // 填加文件主题信息
     66                  si.CreateDateTime  =  DateTime.Now;
     67                  workbook.SummaryInformation  =  si;
     68              }
     69               #endregion
     70 
     71              HSSFCellStyle dateStyle  =  workbook.CreateCellStyle();
     72              HSSFDataFormat format  =  workbook.CreateDataFormat();
     73              dateStyle.DataFormat  =  format.GetFormat( " yyyy-mm-dd " );
     74 
     75               // 取得列宽
     76               int [] arrColWidth  =   new   int [dtSource.Columns.Count];
     77               foreach  (DataColumn item  in  dtSource.Columns)
     78              {
     79                  arrColWidth[item.Ordinal]  =  Encoding.GetEncoding( 936 ).GetBytes(item.ColumnName.ToString()).Length;
     80              }
     81               for  ( int  i  =   0 ; i  <  dtSource.Rows.Count; i ++ )
     82              {
     83                   for  ( int  j  =   0 ; j  <  dtSource.Columns.Count; j ++ )
     84                  {
     85                       int  intTemp  =  Encoding.GetEncoding( 936 ).GetBytes(dtSource.Rows[i][j].ToString()).Length;
     86                       if  (intTemp  >  arrColWidth[j])
     87                      {
     88                          arrColWidth[j]  =  intTemp;
     89                      }
     90                  }
     91              } 
     95               int  rowIndex  =   0 ; 
     97               foreach  (DataRow row  in  dtSource.Rows)
     98              {
     99                   #region  新建表,填充表头,填充列头,样式
    100                   if  (rowIndex  ==   65535   ||  rowIndex  ==   0 )
    101                  {
    102                       if  (rowIndex  !=   0 )
    103                      {
    104                          sheet  =  workbook.CreateSheet();
    105                      }
    106 
    107                       #region  表头及样式
    108                      {
    109                          HSSFRow headerRow  =  sheet.CreateRow( 0 );
    110                          headerRow.HeightInPoints  =   25 ;
    111                          headerRow.CreateCell( 0 ).SetCellValue(strHeaderText);
    112 
    113                          HSSFCellStyle headStyle  =  workbook.CreateCellStyle();
    114                          headStyle.Alignment  =  CellHorizontalAlignment.CENTER;
    115                          HSSFFont font  =  workbook.CreateFont();
    116                          font.FontHeightInPoints  =   20 ;
    117                          font.Boldweight  =   700 ;
    118                          headStyle.SetFont(font);
    119                          headerRow.GetCell( 0 ).CellStyle  =  headStyle;
    120                          sheet.AddMergedRegion( new  Region( 0 0 0 , dtSource.Columns.Count  -   1 ));
    121                          headerRow.Dispose();
    122                      }
    123                       #endregion
    124 
    125 
    126                       #region  列头及样式
    127                      {
    128                          HSSFRow headerRow  =  sheet.CreateRow( 1 ); 
    131                          HSSFCellStyle headStyle  =  workbook.CreateCellStyle();
    132                          headStyle.Alignment  =  CellHorizontalAlignment.CENTER;
    133                          HSSFFont font  =  workbook.CreateFont();
    134                          font.FontHeightInPoints  =   10 ;
    135                          font.Boldweight  =   700 ;
    136                          headStyle.SetFont(font); 
    139                           foreach  (DataColumn column  in  dtSource.Columns)
    140                          {
    141                              headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
    142                              headerRow.GetCell(column.Ordinal).CellStyle  =  headStyle;
    143 
    144                               // 设置列宽
    145                              sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal]  +   1 *   256 ); 
    147                          }
    148                          headerRow.Dispose();
    149                      }
    150                       #endregion
    151 
    152                      rowIndex  =   2 ;
    153                  }
    154                   #endregion
    155 
    156 
    157                   #region  填充内容
    158                  HSSFRow dataRow  =  sheet.CreateRow(rowIndex);
    159                   foreach  (DataColumn column  in  dtSource.Columns)
    160                  {
    161                      HSSFCell newCell  =  dataRow.CreateCell(column.Ordinal);
    162 
    163                       string  drValue  =  row[column].ToString();
    164 
    165                       switch  (column.DataType.ToString())
    166                      {
    167                           case   " System.String " : // 字符串类型
    168                              newCell.SetCellValue(drValue);
    169                               break ;
    170                           case   " System.DateTime " : // 日期类型
    171                              DateTime dateV;
    172                              DateTime.TryParse(drValue,  out  dateV);
    173                              newCell.SetCellValue(dateV);
    174 
    175                              newCell.CellStyle  =  dateStyle; // 格式化显示
    176                               break ;
    177                           case   " System.Boolean " : // 布尔型
    178                               bool  boolV  =   false ;
    179                               bool .TryParse(drValue,  out  boolV);
    180                              newCell.SetCellValue(boolV);
    181                               break ;
    182                           case   " System.Int16 " : // 整型
    183                           case   " System.Int32 " :
    184                           case   " System.Int64 " :
    185                           case   " System.Byte " :
    186                               int  intV  =   0 ;
    187                               int .TryParse(drValue,  out  intV);
    188                              newCell.SetCellValue(intV);
    189                               break ;
    190                           case   " System.Decimal " : // 浮点型
    191                           case   " System.Double " :
    192                               double  doubV  =   0 ;
    193                               double .TryParse(drValue,  out  doubV);
    194                              newCell.SetCellValue(doubV);
    195                               break ;
    196                           case   " System.DBNull " : // 空值处理
    197                              newCell.SetCellValue( "" );
    198                               break ;
    199                           default :
    200                              newCell.SetCellValue( "" );
    201                               break ;
    202                      }
    203 
    204                  }
    205                   #endregion
    206 
    207                  rowIndex ++ ;
    208              } 
    211               using  (MemoryStream ms  =   new  MemoryStream())
    212              {
    213                  workbook.Write(ms);
    214                  ms.Flush();
    215                  ms.Position  =   0 ;
    216 
    217                  sheet.Dispose();
    218                   // workbook.Dispose(); // 一般只用写这一个就OK了,他会遍历并释放所有资源,但当前版本有问题所以只释放sheet
    219                   return  ms;
    220              } 
    222          }
    223 
    224           ///   <summary>
    225           ///  用于Web导出
    226           ///   </summary>
    227           ///   <param name="dtSource"> 源DataTable </param>
    228           ///   <param name="strHeaderText"> 表头文本 </param>
    229           ///   <param name="strFileName"> 文件名 </param>
    230           public   static   void  ExportByWeb(DataTable dtSource,  string  strHeaderText,  string  strFileName)
    231          { 
    233              HttpContext curContext  =  HttpContext.Current;
    234 
    235               //  设置编码和附件格式
    236              curContext.Response.ContentType  =   " application/vnd.ms-excel " ;
    237              curContext.Response.ContentEncoding  =  Encoding.UTF8;
    238              curContext.Response.Charset  =   "" ;
    239              curContext.Response.AppendHeader( " Content-Disposition " ,
    240                   " attachment;filename= "   +  HttpUtility.UrlEncode(strFileName, Encoding.UTF8));
    241 
    242              curContext.Response.BinaryWrite(Export(dtSource, strHeaderText).GetBuffer());
    243              curContext.Response.End(); 
    245          } 
    247 
    248           ///   <summary> 读取excel
    249           ///  默认第一行为标头
    250           ///   </summary>
    251           ///   <param name="strFileName"> excel文档路径 </param>
    252           ///   <returns></returns>
    253           public   static  DataTable Import( string  strFileName)
    254          {
    255              DataTable dt  =   new  DataTable();
    256 
    257              HSSFWorkbook hssfworkbook;
    258               using  (FileStream file  =   new  FileStream(strFileName, FileMode.Open, FileAccess.Read))
    259              {
    260                  hssfworkbook  =   new  HSSFWorkbook(file);
    261              }
    262              HSSFSheet sheet  =  hssfworkbook.GetSheetAt( 0 );
    263              System.Collections.IEnumerator rows  =  sheet.GetRowEnumerator();
    264 
    265              HSSFRow headerRow  =  sheet.GetRow( 0 );
    266               int  cellCount  =  headerRow.LastCellNum;
    267 
    268               for  ( int  j  =   0 ; j  <  cellCount; j ++ )
    269              {
    270                  HSSFCell cell  =  headerRow.GetCell(j);
    271                  dt.Columns.Add(cell.ToString());
    272              }
    273 
    274               for  ( int  i  =  (sheet.FirstRowNum  +   1 ); i  <=  sheet.LastRowNum; i ++ )
    275              {
    276                  HSSFRow row  =  sheet.GetRow(i);
    277                  DataRow dataRow  =  dt.NewRow();
    278 
    279                   for  ( int  j  =  row.FirstCellNum; j  <  cellCount; j ++ )
    280                  {
    281                       if  (row.GetCell(j)  !=   null )
    282                          dataRow[j]  =  row.GetCell(j).ToString();
    283                  }
    284 
    285                  dt.Rows.Add(dataRow);
    286              }
    287               return  dt;
    288          }
    289      }
    290  }
    291 

     

    4、NPOI操作类的调用方法
       DataTable dt_Grade = Tools.Data.GetDataTable(strSQL);
       filename += "绩效考核结果分数统计表";
       PMS.Common.NPOIHelper.ExportByWeb(dt_Grade, filename, filename+".xls");

    5、效果展示
       

    6、NPOI类库下载:http://files.cnblogs.com/dreamof/NPOIç±»åº.rar

    信息来源:http://www.cnblogs.com/yongfa365/archive/2010/05/10/NPOI-MyXls-DataTable-To-Excel-From-Excel.html


    转载请注明本文地址: 【推荐】.NET使用NPOI组件将数据导出Excel
    展开全文
  • 需求:有一张用户表,现在需要点击...实现:使用NPOI组件。在项目中使用Nuget管理器安装NPOI代码如下: private void btnDC_Click(object sender, EventArgs e) { string Desktop = @"C:\Users\Administr...
  • 最终还是要使用NPOi了。...不过这也是一种学习了,呵呵,3种方法都用到了。... 在文章开始必须先申明,我的NPOI组件版本为1.2.4  1.谈谈我用到Com组件和NPOi组件的感觉  》NPOI不用安装Excel,这
  • 1、本源码中有通过NPOI组件读取Excel文件的方法 2、有通过Gmail账户读取账户的联系人 本demo中有现成的dll文件和类,直接引用到你的项目中就可以了。主备以后自己用。
  • NPOI确实是一款在C#中很好用的API,NPOI可以在没有安装Office的情况下对Word或Excel文档进行读写操作。
  • MVC web NPOI 组件导出EXCLE设置其背景色方法
  • 普通的方式Excel的读取和写入,如果遇到大数据量的操作,效率会很低,NPOI组件可以解决这个问题. 一、通过NPOI组件获取Excel所有表(Sheet)名  public List GetSheetName()  {  using (FileStream file = ...
  • C# 根据模板 导出 Excel 图表 (NPOI组件) 我的数据是放在List中的。 //导出  protected void onclickbutton(object sender, EventArgs e)  {  getlist();//取出数据,就不详细说明  }
  • 不用装OFFICE就能进行对Excel进行操作的组件
  •  可以到此网站上去下载最新的NPOI组件版本 2、NPOI在线学习教程(中文版):  http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html  感谢Tony Qu分享出NPOI组件的使用方法 3、.NET调用NPOI组件...
  • Visual Studio 2012 安装NPOI组件时遇到的问题与解决方法 一、想在项目中通过NuGet直接安装NPOI 但是出现如下错误:基础连接已经关闭:发送时发生错误。 网上查的各种方法试了还是不行,估计是被墙了,此路...
  • 组件使用NPOI最新版本,优化了NPOI支持表格宽度自适应(支持中文宽度自适应)。 如需在IIS下运行IIS要求IIS6.0以上(支持.net),应用程序池中.NET Framework需要选v4.0。 ASP使用列子参看ASP demo 使用组件需要IIS...
  • C# 操作excel 用的NPOI 开源组件包 ,版本号2.0.1.0。 1、您可以完全免费使用该框架 2、包含了大部分EXCEL的特性(单元格样式、数据格式、公式等等) 3、专业的技术支持服务(24*7全天候) (非免费) 4、支持处理的文件...
  • 可以到此网站上去下载最新的NPOI组件版本 2、NPOI在线学习教程(中文版): http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html 感谢Tony Qu分享出NPOI组件的使用方法 3、.NET调用NPOI组件导入...
  • NPOI组件强大高效,这里只使用它完成我们的Excel写入功能,需要更多内容则请自行搜索。 IWorkbook:工作簿对象,可以由NPOI.HSSF.UserModel.HSSFWorkbook实例化得来,Write(Stream stream)如其意; ISheet:工作...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 2,656
精华内容 1,062
关键字:

npoi组件