精华内容
下载资源
问答
  • Excel表格操作类、搜索、NPOI示例等、c#中高效的excel导入sqlserver的方法,ExcelHelper等一些基本类,平时收集一些类,提供参考
  • 详情见博主的博客《NPOI 第二篇 设置样式与合并单元格》,地址为: https://blog.csdn.net/wf824284257/article/details/85920867
  • npoi使用示例.rar

    2019-11-20 20:33:38
    npoi使用示例npoi使用示例
  • NPOI示例

    2015-06-25 15:06:34
    npoi 2.1.1 examples net2.0 net 4.0
  • NPOI导出Excel示例

    2013-10-07 11:18:00
    NPOI首页地址:http://npoi.codeplex.com/,NPOI示例博客:http://tonyqus.sinaapp.com/。 示例编写环境: 操作系统:Windows7 Ultimate SP1 64bit 开发软件:Visual Studio Ultimate 2012 Update 3 Office版本...

    摘要:使用开源程序NPOI导出Excel示例。NPOI首页地址:http://npoi.codeplex.com/,NPOI示例博客:http://tonyqus.sinaapp.com/。

    示例编写环境:

    操作系统:Windows7 Ultimate SP1 64bit

    开发软件:Visual Studio Ultimate 2012 Update 3

    Office版本:Office Home and Student 2010

    NPOI版本:NPOI 2.0

     

    示例界面如下:

    本示例中使用到的命名空间:

     1 using System;
     2 using System.Data;
     3 using System.Web;
     4 using System.Web.UI;
     5 using System.Collections.Generic;
     6 using System.Web.UI.WebControls;
     7 using System.IO;
     8 using System.Text;
     9 using NPOI.SS.UserModel;
    10 using NPOI.HSSF.UserModel;
    11 using NPOI.HSSF.Util;
    12 using NPOI.HPSF;
    13 using NPOI.POIFS.FileSystem;
    14 using NPOI.SS.Util;

    导出按钮代码:

     1 protected void btnExportClick(object sender, EventArgs e)
     2 {
     3     // 文件名最好使用英文,中文可能会出现乱码或者丢失文件后缀
     4     string filename = "ReportExport" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
     5     Response.Clear();
     6     Response.ContentType = "application/vnd.ms-excel";
     7     Response.AppendHeader("Content-Type", "applicationnd.ms-excel");
     8     Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
     9 
    10     // getData()函数返回一个DataTable类型,在本实例中用于获得要导出的数据,可根据项目情况替换该函数
    11     Response.BinaryWrite(getExportContent(getData()).GetBuffer());
    12     Response.Flush();
    13     // 若使用Response.End方法会导致ThreadAbortException 异常,使用下面的语句替换Response.End方法
    14     HttpContext.Current.ApplicationInstance.CompleteRequest();
    15 }

     

    负责生成导出信息的方法getExportContent示例代码如下:

     1 private MemoryStream getExportContent(DataTable table)
     2 {
     3     // 添加Excel元数据信息
     4     HSSFWorkbook book = new HSSFWorkbook();
     5     DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
     6     dsi.Company = "MyCompany";
     7     book.DocumentSummaryInformation = dsi;
     8 
     9     SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
    10     si.Subject = "MySubject";
    11     book.SummaryInformation = si;
    12 
    13     // 声明必要的变量
    14     MemoryStream ms = new MemoryStream();
    15     ISheet sheet = book.CreateSheet("sheet1");
    16     IRow erow = sheet.CreateRow(0);
    17 
    18     // 设置列宽,列宽的单位是256分之一字符,所以10*256表示10个字符宽度
    19     sheet.SetColumnWidth(1, 20 * 256);
    20     sheet.SetColumnWidth(2, 20 * 256);
    21     sheet.SetColumnWidth(3, 10 * 256);
    22     sheet.SetColumnWidth(4, 10 * 256);
    23 
    24     // 增加表头
    25     buildSheetTitle(book);
    26 
    27     // 增加内容,标题占两行,从第三行添加数据内容。
    28     // 在NPOI中行列以0作为起始
    29     int rindex = 2;
    30     foreach (DataRow r in table.Rows)
    31     {
    32         erow = sheet.CreateRow(rindex);
    33         // 序号
    34         erow.CreateCell(0).SetCellValue(rindex - 1);
    35         for (int c = 0; c < table.Columns.Count; c++)
    36         {
    37             erow.CreateCell(c + 1).SetCellValue(r[c].ToString());
    38         }
    39         rindex++;
    40     }
    41     //  对相同的列进行纵向合并
    42     mergeColumn(book);
    43 
    44 
    45     book.Write(ms);
    46     ms.Flush();
    47     ms.Position = 0;
    48     return ms;
    49 }

     

    增加表头方法buildSheetTitle示例代码:

     1 private void buildSheetTitle(HSSFWorkbook book)
     2 {
     3     // 定义必要变量
     4     ISheet sheet = book.GetSheetAt(0);
     5     IRow erow = sheet.CreateRow(0);
     6     ICell cell = null;
     7     // 单元格样式
     8     ICellStyle style = book.CreateCellStyle();
     9     style.Alignment = HorizontalAlignment.CENTER;
    10     style.VerticalAlignment = VerticalAlignment.CENTER;
    11     IFont font = book.CreateFont();
    12     font.FontHeightInPoints = 12;
    13     font.FontName = "宋体";
    14     style.SetFont(font);
    15 
    16     // 增加第一行标题
    17     cell = erow.CreateCell(0);
    18     cell.SetCellValue("序号");
    19     cell.CellStyle = style;
    20     sheet.AddMergedRegion(new CellRangeAddress(0, 1, 0, 0));
    21 
    22     cell = erow.CreateCell(1);
    23     cell.SetCellValue("装置名称");
    24     cell.CellStyle = style;
    25     sheet.AddMergedRegion(new CellRangeAddress(0, 1, 1, 1));
    26 
    27     cell = erow.CreateCell(2);
    28     cell.SetCellValue("物料信息");
    29     cell.CellStyle = style;
    30     sheet.AddMergedRegion(new CellRangeAddress(0, 0, 2, 3));
    31 
    32     // 增加第二行标题
    33     erow = sheet.CreateRow(1);
    34     cell = erow.CreateCell(2);
    35     cell.SetCellValue("物料名称");
    36     cell.CellStyle = style;
    37     cell = erow.CreateCell(3);
    38     cell.SetCellValue("小计");
    39     cell.CellStyle = style;
    40 }

     

    合并单元格方法mergeColumn示例代码如下:

     1 private void mergeColumn(HSSFWorkbook book)
     2 {
     3     ISheet sheet = book.GetSheetAt(0);
     4     int cunit = 1;
     5     // 合并单元格跨越的行数
     6     int rspan = 0;
     7     // 需合并单元格的起始行,前两行为标题,默认起始行是第三行
     8     int srow = 2;
     9 
    10     // 单元格字体样式
    11     IFont font = book.CreateFont();
    12     font.FontHeightInPoints = 12;
    13     font.FontName = "宋体";
    14 
    15     // 非合并单元格样式
    16     ICellStyle style = book.CreateCellStyle();
    17     style.SetFont(font);
    18 
    19     // 合并单元格样式
    20     ICellStyle mstyle = book.CreateCellStyle();
    21     mstyle.Alignment = HorizontalAlignment.CENTER;
    22     mstyle.VerticalAlignment = VerticalAlignment.CENTER;
    23     mstyle.SetFont(font);
    24 
    25 
    26     // 合并单元格
    27     string oldvalue = string.Empty;
    28     for (int r = 2; r < sheet.PhysicalNumberOfRows; r++)
    29     {
    30         if (sheet.GetRow(r).GetCell(cunit).StringCellValue == oldvalue)
    31         {
    32             rspan++;
    33         }
    34         else
    35         {
    36             // 添加合并区域
    37             sheet.AddMergedRegion(new CellRangeAddress(srow, srow + rspan, 1, 1));
    38             oldvalue = sheet.GetRow(r).GetCell(cunit).StringCellValue;
    39             srow = r;
    40             rspan = 0;
    41         }
    42     }
    43 
    44     // 对未合并的单元格进行合并
    45     if (rspan != 0)
    46     {
    47         sheet.AddMergedRegion(new CellRangeAddress(srow, srow + rspan, 1, 1));
    48     }
    49 
    50     // 调整合并单元格的样式
    51     for (int c = 0; c < 4; c++)
    52     {
    53         for (int r = 2; r < sheet.PhysicalNumberOfRows; r++)
    54         {
    55             if (c == cunit)
    56             {
    57                 sheet.GetRow(r).GetCell(c).CellStyle = mstyle;
    58             }
    59             else
    60             {
    61                 sheet.GetRow(r).GetCell(c).CellStyle = style;
    62             }
    63         }
    64     }
    65 }

     

    导出后的文件内容:

    转载于:https://www.cnblogs.com/shenyuelan/p/3355069.html

    展开全文
  • NPOI读取示例

    2020-10-03 21:49:52
    using NPOI.HSSF.Record.Aggregates; using NPOI.HSSF.UserModel; using NPOI.XWPF.UserModel; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading....

    通过流生成 excel

    using Microsoft.AspNetCore.Mvc;
    
    using NPOI.HSSF.Record.Aggregates;
    using NPOI.HSSF.UserModel;
    using NPOI.XWPF.UserModel;
    
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Threading.Tasks;
    
    namespace NpoiDemo.Common
    {
        using S = String;
        public class ZJDelivery:CustomReportBase
        {
            public static FileContentResult GetCDFPickDetail(List<CDFPickDetail> handover)
            {
                var hssfworkbook = new HSSFWorkbook();
    
                var sheet1 = hssfworkbook.CreateSheet("Sheet1");
                var font = hssfworkbook.CreateFont();
                font.FontName = "Times New Roman";
                font.FontHeightInPoints = 11;
                var style = hssfworkbook.CreateCellStyle();
                style.SetFont(font);
    
                var font2 = hssfworkbook.CreateFont();
                font2.FontName = "Times New Roman";
                font2.FontHeightInPoints = 36;
    
                #region   {第一行}
                var s1Row1Style = hssfworkbook.CreateCellStyle();
    
                var r1 = sheet1.CreateRow(0);
                r1.HeightInPoints = 46.5f;
                var r1c1Style = hssfworkbook.CreateCellStyle();
                r1c1Style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
                r1c1Style.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
                r1c1Style.SetFont(font2);
    
                var r1c1 = r1.CreateCell(0);
                r1c1.SetCellValue("VIP 理 货 单");
                r1c1.CellStyle = r1c1Style;
                Enumerable.Range(1, 19).ToList().ForEach(x =>
                {
                    r1.CreateCell(x).SetCellValue("");
                });
    
                sheet1.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, 18));
    
                #endregion
    
                #region{第二行}
                var r2 = sheet1.CreateRow(1);
                var r2c1 = r2.CreateCell(0);
    
                r2c1.SetCellValue($"Date:{DateTime.Now.ToString("dd-MM-yyyy")}");
                r2c1.CellStyle = style;
                Enumerable.Range(1, 19).ToList().ForEach(x =>
                {
                    r2.CreateCell(x).SetCellValue("");
                });
                #endregion
                #region   {第三行-空白行}
                var r3 = sheet1.CreateRow(2);
                Enumerable.Range(0, 19).ToList().ForEach(x =>
                {
                    r3.CreateCell(x).SetCellValue("");
                });
                #endregion
    
                var fontCotent = hssfworkbook.CreateFont();
                font.FontName = "Times New Roman";
                font.FontHeightInPoints = 11;
                var contentStyle = hssfworkbook.CreateCellStyle();
                contentStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
                contentStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
                contentStyle.SetFont(font);
                setBorderStyle(contentStyle,NPOI.SS.UserModel.BorderStyle.Medium);
    
                #region   {第四行,列名}
                var r4 = sheet1.CreateRow(3);
                var r4Col = new List<S>
                {
                    "VIP",
                    "ItemID",
                    "UPC",
                    "C Code",
                    "Product",
                    "QTY",
                    "Inventory",
                    "Location"
                };
                Enumerable.Range(0, r4Col.Count).ToList().ForEach(x =>
                {
                    r4.CreateCell(x).SetCellValue(r4Col[x]);
                    r4.Cells[x].CellStyle = contentStyle;
    
                });
                var r4c9 = r4.CreateCell(r4Col.Count);
                var r4c9Style = hssfworkbook.CreateCellStyle();
                r4c9.CellStyle = contentStyle;
                r4c9.SetCellValue("Cantons Detail");
                Enumerable.Range(0, 8).ToList().ForEach(x =>
                {
                    r4.CreateCell(x + 9).SetCellValue("");
                    r4.Cells[x + 9].CellStyle = contentStyle;
                });
                sheet1.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(3, 3, 8, 15));
    
                var r4Col2 = new List<S>
                {
                    "Lot",
                    "Cantons",
                    "Remark",
                };
                Enumerable.Range(0, 3).ToList().ForEach(x =>
                {
                    r4.CreateCell(x + 16).SetCellValue(r4Col2[x]);
                    r4.Cells[x + 16].CellStyle = contentStyle;
                });
                #endregion
    
    
                //数据填充
                var rIndex = 4;
                var calcIndex = 5;
                handover.ForEach(x =>
                {
                    var r = sheet1.CreateRow(rIndex++);
                    r.CreateCell(0).SetCellValue("");//vip 后面需要进行合并
                    r.CreateCell(1).SetCellValue(x.ItemID);
                    r.CreateCell(2).SetCellValue(x.UPC);
                    r.CreateCell(3).SetCellValue(x.CCode);
                    r.CreateCell(4).SetCellValue(x.Product);
                    r.CreateCell(5).SetCellValue(x.QTY);
                    r.CreateCell(6).SetCellValue("");//Inventory
                    r.CreateCell(7).SetCellValue("");//location
                    r.CreateCell(8).SetCellValue("");//input qty
                    r.CreateCell(9).SetCellValue("pcs");
                    r.CreateCell(10).SetCellValue("");//input qty
                    r.CreateCell(11).SetCellValue("ctn");
                    r.CreateCell(12).SetCellValue("");//input qty
                    r.CreateCell(13).SetCellValue("pcs");
                    r.CreateCell(14).SetCellValue("");//input qty
                    r.CreateCell(15).SetCellValue("ctn");
                    r.CreateCell(16).SetCellValue("");//lot
                    var m = r.CreateCell(17);
                    m.SetCellValue("");//Cantons
                    m.SetCellFormula($"SUM(K{calcIndex},O{calcIndex})");
                    r.CreateCell(18).SetCellValue("");//Remark
                    Enumerable.Range(0, 19).ToList().ForEach(y =>
                    {
                        r.Cells[y].CellStyle = contentStyle;
                    });
                    calcIndex++;
                });
    
                Enumerable.Range(0, 2).ToList().ForEach(x=> {
                    var r = sheet1.CreateRow(rIndex++);
                    Enumerable.Range(0, 19).ToList().ForEach(y=>{
                        r.CreateCell(y).SetCellValue("");
                    });
                });
                //vip列合并
                sheet1.GetRow(4).Cells[0].SetCellValue(handover.First().VIP);
                sheet1.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(4, handover.Count+3, 0, 0));
    
                //理货人
                var rlast = sheet1.CreateRow(rIndex);
                var rlastc1 = rlast.CreateCell(0);
                rlastc1.SetCellValue("理货人员签名:");
                rlastc1.CellStyle = style;
                //自适应列宽
                Enumerable.Range(0, 19).ToList().ForEach(x =>
                {
                    sheet1.AutoSizeColumn(x);
                });
                //固定宽度设置
                Enumerable.Range(0, 8).ToList().ForEach(x =>
                {
                    sheet1.SetColumnWidth(x+8, 5 * 256);
                });
                var bytes = new byte[] { };
                using (var ms = new MemoryStream())
                {
                    hssfworkbook.Write(ms);
                    ms.Flush();
                    ms.Position = 0;
                    bytes = ms.GetBuffer();
                }
                return new FileContentResult(bytes, "application/vnd.ms-excel")
                {
                    FileDownloadName = $"VIP拣货明细表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"
                };
            }
    
        }
    
        public class CDFPickDetail
        {
            public S VIP { get; set; }
            public S ItemID { get; set; }
            public S UPC { get; set; }
            public S CCode { get; set; }
            public S Product { get; set; }
            public S QTY { get; set; }
            public S Inventory { get; set; }
            public S Location { get; set; }
            public S CantonsDetail { get; set; }
            public S Lot { get; set; }
            public S Cantons { get; set; }
            public S Remark { get; set; }
        }
    }
    
    
    展开全文
  • NPOI简单示例

    2016-12-06 17:56:00
    导出常用方法示例(使用该方法时需先引入NPOI.dll文件): /// <summary> /// 导出基本操作示例方法 /// </summary> public static void ExportExcel() { try { //...

     

    导出常用方法示例(使用该方法时需先引入NPOI.dll文件):

    /// <summary>
    /// 导出基本操作示例方法
    /// </summary>
    public static void ExportExcel()
    {
    try
    {
    //初始化一个新的HSSFWorkbook实例
    HSSFWorkbook hssfworkbook = new HSSFWorkbook();

    //设置excel必须的文件属性(该属性用来存储 如作者、标题、标记、备注、主题等信息,右键可查看的属性信息)
    DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
    dsi.Company = "NPOI Team";
    SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
    si.Subject = "NPOI SDK Example";
    hssfworkbook.DocumentSummaryInformation = dsi;
    hssfworkbook.SummaryInformation = si;


    //新建一个Workbook默认都会新建3个Sheet(标准的Excel文件有3个Sheet)。所以必须加入下面的创建Sheet的代码才能保证生成的文件正常
    HSSFSheet sheet = (HSSFSheet)hssfworkbook.CreateSheet("new sheet");
    hssfworkbook.CreateSheet("Sheet1");
    hssfworkbook.CreateSheet("Sheet2");
    hssfworkbook.CreateSheet("Sheet3");

    //建创行
    IRow row1=sheet.CreateRow(0);
    //建单元格,比如创建A1位置的单元格:
    row1.CreateCell(0).SetCellValue(1);
    //简写 shee1.CreateRow(0).CreateCell(0).SetCellValue("This is a Sample");

    //把C3:E5合并为一个单元格 并赋值
    ICell cell= sheet.CreateRow(2).CreateCell(2);
    cell.SetCellValue("This is a Sample");
    sheet.AddMergedRegion(new Region(2, 2, 4, 4));

    //设置样式 居中 字体
    ICellStyle style = hssfworkbook.CreateCellStyle();
    style.VerticalAlignment = VerticalAlignment.Center;
    style.Alignment = HorizontalAlignment.Center;
    IFont font = hssfworkbook.CreateFont();
    font.FontHeight = 20 * 20;
    style.SetFont(font);
    cell.CellStyle = style;


    //把这个HSSFWorkbook实例写入文件
    FileStream file = new FileStream(@"F:\\test.xls", FileMode.Create);
    hssfworkbook.Write(file);
    file.Close();
    }
    catch (Exception e)
    {
    throw new Exception(e.ToString());
    }
    }

    转载于:https://www.cnblogs.com/luoxiaoxiao102/p/6138523.html

    展开全文
  • Excel NPOI读写示例

    2019-06-13 19:06:04
    来自于 http://blog.abcenter.xyz/2019/06/13/excel-npoi读写示例 Epplus:Nuget地址,项目地址 参考:Epplus上手 /// <summary> /// 从Excel中第一列第二行起取数据,并查询oracle数据库中数据取ima70字段值...

    来自于 http://blog.abcenter.xyz/2019/06/13/excel-npoi读写示例

    Epplus:Nuget地址项目地址

    参考:Epplus上手

     /// <summary>
    /// 从Excel中第一列第二行起取数据,并查询oracle数据库中数据取ima70字段值写入同行的第二列
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button46_Click(object sender, EventArgs e)
    {
        //Opening an existing Excel file
        FileInfo fi = new FileInfo(@"D:\Luxshare-ict2019\工作\SAP切换\料号对比\目标数据\Compare.xlsx");
        using (ExcelPackage excelPackage = new ExcelPackage(fi))
        {
            //Get a WorkSheet by index. Note that EPPlus indexes are base 1, not base 0!
            ExcelWorksheet firstWorksheet = excelPackage.Workbook.Worksheets[1];
    
            Get a WorkSheet by name. If the worksheet doesn't exist, throw an exeption
            //ExcelWorksheet namedWorksheet = excelPackage.Workbook.Worksheets["SomeWorksheet"];
    
            If you don't know if a worksheet exists, you could use LINQ,
            So it doesn't throw an exception, but return null in case it doesn't find it
            //ExcelWorksheet anotherWorksheet =
            //    excelPackage.Workbook.Worksheets.FirstOrDefault(x => x.Name == "SomeWorksheet");
    
            string cOString = "data source=topprod;user id=帐号;password=密码;Unicode=True";
            OracleConnection con = new OracleConnection();
            con.ConnectionString = cOString;
            con.Open();
    
            ExcelWorksheets worksheets = excelPackage.Workbook.Worksheets;//取Excel的所有Sheet
            string part = string.Empty;
            string ima70 = string.Empty;
            string sqlStr = string.Empty;
            foreach (var worksheet in worksheets)
            {
                int rowCount = worksheet.Dimension.End.Row;//sheet行数
                for (int i = 2; i <= rowCount; i++)//从第2行取到最后一行
                {
                    part= worksheet.Cells[i, 1].Value.ToString();
                    if (string.IsNullOrWhiteSpace(part))
                    {
                        continue;
                    }
                    sqlStr = $"SELECT IMA70 FROM LXXT.IMA_FILE WHERE IMA01 ='{part}'";
                    OracleDataAdapter oda = new OracleDataAdapter(sqlStr, con);
                    System.Data.DataSet ods = new System.Data.DataSet();
                    oda.Fill(ods);
                    //ods.Tables[0];
                    if (ods.Tables[0].Rows.Count>0)
                    {
                        worksheet.Cells[i, 2].Value = ods.Tables[0].Rows[0][0].ToString();//如果从数据库中取导致,写入第二列
                    }
                    System.Diagnostics.Debug.WriteLine($"{worksheet.Name}:{i.ToString()},{part}");//实时查看处理进度。
                    //if (i>4)
                    //{
                    //    break;
                    //}
                }
                //break;
            }
            //Save your file
            excelPackage.Save();
    
            con.Close();
    
        }
    
    展开全文
  • 包含.net2.0和4.0两个版本的dll,以及相关的示例,希望对各位有所帮助
  • NPOI编辑Word示例.docx

    2021-03-18 10:48:47
    NPOI编辑Word示例.docx
  • NPOI示例程序(c#)

    2010-03-26 10:18:50
    NPOI Example Package 20091205
  • /// <summary> /// 创建sheet中的行和列 /// </summary> /// <param name="sheet"></param> /// <param name="rowcount"></param> /// <...
  • 直接上代码,代码中有详细的注释。这个东西可真“别扭”(对...官网:http://npoi.codeplex.com/ 中文教程(旧版):http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html   //-
  • 该资源包括NPOI类库与VS2010示例源码,解压即可运行,实行Excel的创建,读取,写入、sheet操作等功能
  • 使用 NPOI 导出数据示例

    千次阅读 2011-01-23 21:46:00
    这个东西可真“别扭”(对多数 .NET 来讲,他们喜欢优雅、直接、明了、带注释、智能提示的编码方式) 官网:http://npoi.codeplex.com/<br />中文教程(旧版):...
  • NPOI操作Excel简单示例

    2015-09-22 10:58:35
    根据网上的资料,学习了一下NPOI操作Excel的基本方法: 1、导出至Excel:标题行合并居中、设置列宽、写入列标题及数据。 public class ExportToExcel : IHttpHandler //一般处理程序ExportToExcel.ashx { public...
  • NPOI是POI的.net版本, 是能够帮助开发者在没有安装微软office的情况下读写office文件,支持的文件包括excel,word,ppt等NPOI.Util 基础辅助库NPOI.POIFS OLE2格式读写库NPOI.DDF Micosoft Drawing格式读写库NPOI....
  • NPOI生成EXECL简单示例

    千次阅读 2011-12-26 21:50:22
    using System; using System.Data; using System.Data.SqlClient; using System.Web;...using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; namespace WebApplication1 { public partial class Default : Syst
  • //列宽自适应,只对英文和数字有效 for (int i = 0; i <= maxColumn; i++) { sheet.AutoSizeColumn(i); } //获取当前列的宽度,然后对比本列的长度,取最大值 for (int columnNum = 0;... int...
  • NPOI 2.0将DataTable对象转换为Excel 2007文件提供下载 代码如下:using NPOI.SS.UserModel;using NPOI.XSSF.UserModel;using System.IO; private Stream RenderDataTableToExcel(DataTable SourceTable) { ...
  • 下面小编就为大家分享一篇NPOI实现两级分组合并功能的示例讲解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
  • NPOI(Excel操作开源类库)源码及示例 很不错的一个类库
  • Winform中使用NPOI实现导出Excel并文件另存为示例代码
  • Winform中使用NPOI实现Excel导入并赋值给DataTable示例代码

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,119
精华内容 447
热门标签
关键字:

npoi的示例