Example #1
0
        /// <summary>
        /// 获得模版
        /// </summary>
        /// <returns></returns>
        public void GetTemp()
        {
            String     fileName = Server.MapPath("/File/expBank.xls");
            FileStream stream   = System.IO.File.OpenRead(fileName);
            IWorkbook  excel    = ExcelOperations.GetIWorkbook(stream, ExcelType.xls);
            ISheet     sheet    = excel.GetSheet("Life");

            List <Diction> dictions = new BLL.LifeMan.BLDiction().Select(new HashTableExp("ParentId", "1000200000"), String.Empty);

            for (int i = 0; i < dictions.Count; i++)
            {
                sheet.CreateRow(i + 2).CreateCell(8).SetCellValue(dictions[i].Name);
            }

            dictions = new BLL.LifeMan.BLDiction().Select(new HashTableExp("ParentId", "1000100000"), String.Empty);
            for (int i = 0; i < dictions.Count; i++)
            {
                sheet.CreateRow(i + 5).CreateCell(6).SetCellValue(dictions[i].Name);
            }

            sheet = null;

            MemoryStream ms = new MemoryStream();

            excel.Write(ms);
            Response.AppendHeader("Content-Disposition", "attachment;filename=银行信息模版.xls");
            Response.BinaryWrite(ms.ToArray());
            Response.End();
            ms.Close();
            ms = null;
        }