public void GetTestMoudleAllInfoTest()
        {
            TestMoudleBll tc = new TestMoudleBll();

            int[] an = tc.GetRandom(70);
            Assert.Fail();
        }
Exemple #2
0
        public ActionResult TestModuleExcelExport()
        {
            DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile");
            TestMoudleBll tmBll = new TestMoudleBll();
            // 1.获取数据集合
            List <TestMoudle> list = tmBll.GetTestMoudleAllInfo(CookieHelper.GetCookie("NK"));

            // 2.设置单元格抬头
            // key:实体对象属性名称,可通过反射获取值
            // value:Excel列的名称
            Dictionary <string, string> cellheader = new Dictionary <string, string> {
                { "GradeCode", "年级" },
                { "ClassCode", "班级编号" },
                { "ClassName", "班级名称" },
                { "ItemName", "项目名称" },
                { "TestTeacher", "测试老师" },
                { "TestTime", "测试时间" },
                { "TestAddress", "测试地点" },
                { "TestMaterial", "测试器材" },
                { "TestType", "测试方式(手工/仪器)" },
            };
            // 3.进行Excel转换操作,并返回转换的文件下载链接
            string urlPath = DeriveExcel.ListToExcel2003(cellheader, list, "测试信息模版");
            var    path    = Server.MapPath("~/" + urlPath);
            var    name    = Path.GetFileName(path);

            return(File(path, "application/vnd.ms-excel", name));
        }