C#添加NPOI.dll导出excel

   var book = new HSSFWorkbook();
            var sheet = book.CreateSheet("学生信息表");
            string[] headcell = { "学号", "姓名", "年龄", "性别" };
            var row0 = sheet.CreateRow(0);
            for (int i = 0; i < headcell.Length; i++)
            {
                var cell = row0.CreateCell(i);
                cell.SetCellValue(new HSSFRichTextString(headcell[i]));
            }
            using (var ms = new MemoryStream())
            {
                book.Write(ms);
   
                Response.Clear();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment; filename=1.xls");
                Response.Buffer = true;
                Response.ContentType = "application/ms-excel";
                Response.BinaryWrite(ms.ToArray());

            }

C#添加NPOI.dll导出excel

上一篇:VMware workstation安装Centos7.2系统


下一篇:Windows2008搭建ISS及ftp和dns完成dreamweaver自动上传发布