コード例 #1
0
        /// <summary>
        /// 详情页
        /// </summary>
        /// <returns></returns>
        public ActionResult Detail(int group = 0)
        {
            //这里写要显示什么数据
            string path = Path.Combine(Request.MapPath("~/Upload"), "data.xlsx");

            ViewBag.length  = ExcelUtility.GetGroupLengthByPath(path);
            ViewBag.current = group;
            DataTable data = ExcelUtility.GetDataByPathAndGroupId(path, group);
            //现在要做的就是把前面的注释补上。然后把这个data以表格形式显示出来
            List <DataClass> list = new List <DataClass>();
            int RowCount          = data.Rows.Count;

            DataUtility.CalAB(data);


            for (int i = 0; i < RowCount; i++)
            {
                list.Add(new DataClass {
                    Distance = data.Rows[i][0].ToString(), ZV = data.Rows[i][1].ToString(), FV = data.Rows[i][2].ToString()
                });
            }

            ViewBag.y1         = DataUtility.a + Convert.ToDouble(data.Rows[0][0]) * DataUtility.b;
            ViewBag.y2         = DataUtility.a + Convert.ToDouble(data.Rows[RowCount - 1][0]) * DataUtility.b;
            ViewBag.x1         = data.Rows[0][0];
            ViewBag.x2         = data.Rows[RowCount - 1][0];
            ViewBag.Expression = "Y = " + DataUtility.b.ToString("0.0000") + " * X + " + DataUtility.a.ToString("0.0000");
            ViewBag.xxd        = (DataUtility.xxd(data) * 100).ToString("0.00") + "%";
            ViewBag.lmd        = DataUtility.b.ToString("0.0000");
            ViewBag.cz         = (DataUtility.cz(data) * 100).ToString("0.00") + "%";

            double U, Q, S, N, M;

            U           = DataUtility.U;
            M           = DataUtility.M;
            S           = DataUtility.S;
            Q           = DataUtility.Q;
            N           = DataUtility.N;
            ViewBag.a11 = U.ToString("0.0000");
            ViewBag.a12 = M;
            ViewBag.a13 = (U / M).ToString("0.0000");
            ViewBag.a14 = (U / M / (Q / (N - M - 1))).ToString("0.0000");
            ViewBag.a21 = Q.ToString("0.0000");
            ViewBag.a22 = N - M - 1;
            ViewBag.a23 = (Q / (N - M - 1)).ToString("0.0000");
            ViewBag.a31 = S.ToString("0.0000");
            ViewBag.a32 = N - 1;

            if (group == ExcelUtility.GetGroupLengthByPath(path) - 1)
            {
                ViewBag.cfx = (DataUtility.cfx(ExcelUtility.DataTableFromPath(path)) * 100).ToString("0.00") + "%";
            }

            ViewBag.Data = list;
            return(View(list));
        }