public IActionResult Excel()
        {
            List <List <string[]> > title = new List <List <string[]> >();

            title.Add(new List <string[]>()
            {
                new string[2] {
                    "XX公司", "@"
                }
            });
            title.Add(new List <string[]>()
            {
                new string[2] {
                    "員工", "@"
                }
            });
            title.Add(new List <string[]>()
            {
                new string[2] {
                    "部門", "@"
                },
                new string[2] {
                    "人事部", "@"
                }
            });

            var dto = DataToExcel.DataToExcelDataType(employees, title, new string[]
                                                      { nameof(Employee.Id),
                                                        nameof(Employee.Name),
                                                        nameof(Employee.Salary),
                                                        nameof(Employee.Seniority),
                                                        nameof(Employee.Currency) });

            return(DataToExcel.ToExcel(this, dto, "XX公司-員工表", "員工表"));
        }
        private void ToExcel()
        {
            if (Session["DataTables"] == null)
            {
                this.RegisterStartupScript("无结果", "<script>alert('请先进行统计!');</script>");
                return;
            }

            Dictionary <string, DataTable> dataTables = Session["DataTables"] as Dictionary <string, DataTable>;

            if (dataTables == null)
            {
                this.RegisterStartupScript("无结果", "<script>alert('请先进行统计!');</script>");
                return;
            }

            try
            {
                DataToExcel dte = new DataToExcel();
                dte.DataGridViewToExcel(dataTables);
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(ex.ToString());
            }
        }
Beispiel #3
0
        void ExpoertExcel()
        {
            //Response.Write("<script>CallWriteExportStat('12');</script>");
            //Response.Write("<script>CallWriteExportStat(12,35)</script>");
            //Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"xx","alert('12');");
            // return;
            string condtion = GetCondtion();
            string sql      = @"select
            (select module_name from module_info where id = (select exami_module from exam_layout where id = b.layout_id)) as module_name,
            (select user_name from user_info where id =b.user_id ) as user_name,
            (select user_sex from user_info where id = b.user_id) as user_sex,
            b.user_card,
            (select work_name from work_info where id = b.work_id) as work_name,
            (select exami_name from exam_layout where id = b.layout_id ) as exami_name,
            b.score from exami_info b";
            //计算统计总数,总分页数
            DataTable Art_Table = DataCenter.Instans.SearchTb(string.Format("select count(id) as ct from exami_info b {0}", condtion));
            int       Datacount = int.Parse(Art_Table.Rows[0]["ct"].ToString());
            double    dx        = ((double)Datacount / EvPage);
            int       SumPage   = (int)Math.Ceiling(dx);//总页数
            //组合导出条件
            var item = new ExportContion()
            {
                sql = sql, condtion = condtion, DataCount = Datacount, SumPage = SumPage, EvePage = EvPage
            };

            DataToExcel.ExportExcelTemplate(item, ExcelPath, "公考成绩查询统计表", 3, 1, "", "", "");
        }
Beispiel #4
0
    //public Vector3 Update(Vector3 in_to_target, float in_time)
    //{
    //    float prev_vel = _velocity;
    //    shift = _velocity * in_time + _acceleration * in_time * in_time / 2;
    //    _velocity += _acceleration * in_time;
    //    _current_time += in_time;
    //    float time_left = _time_to_approach / 2 - _current_time;

    //    //if (in_to_target.magnitude <= 0.01f)
    //    //    return Vector3.negativeInfinity;

    //    if (time_left >= 0.00001f && !Mathf.Approximately(time_left, 0f))
    //    {
    //        _acceleration = CalculateAcceleration((in_to_target - _initial_distance / 2).magnitude, _velocity, time_left);
    //        Debug.Log(string.Format("ACCELERATION Time Left = {0}; Velocity = {1}, Acceleration = {2}, Shift = {3}, Distance to Target = {4}",
    //        time_left, _velocity, _acceleration, shift, (in_to_target - _initial_distance / 2).magnitude));
    //    }

    //    else
    //    {
    //        if (!_initial_velocity_to_deaccelerate.HasValue)
    //            _initial_velocity_to_deaccelerate = _velocity;
    //        time_left = _time_to_approach / 2 + time_left;
    //        _acceleration = CalculateDeaccelerationDistance(_initial_velocity_to_deaccelerate.Value, _time_to_approach / 2);
    //        Debug.Log(string.Format("DEACCELERATION Time Left = {0}; Velocity = {1} [{5}], Acceleration = {2}, Shift = {3}, Distance to Target = {4}",
    //        time_left, _velocity, _acceleration, shift, in_to_target.magnitude, prev_vel));
    //    }



    //    return shift * in_to_target.normalized;
    //}

    public Vector3 Update(float in_time, Vector3 cur_pos, Vector3 end_pos)
    {
        _current_time += in_time;
        float time_left = _time_to_approach / 2 - _current_time;

        //return WeightedAverage(cur_pos, end_pos, 3f);
        float new_pos_x = SmoothMovement(in_time, cur_pos.x, end_pos.x, ref _velocity_vector.x, time_left, _max_velocity);
        float new_pos_y = SmoothMovement(in_time, cur_pos.y, end_pos.y, ref _velocity_vector.y, time_left, _max_velocity);
        float new_pos_z = SmoothMovement(in_time, cur_pos.z, end_pos.z, ref _velocity_vector.z, time_left, _max_velocity);

        _velocity_vector = new Vector3(_velocity_vector.x, _velocity_vector.y, _velocity_vector.z);
        Vector3 new_pos = new Vector3(new_pos_x, new_pos_y, new_pos_z);

        Debug.Log(string.Format("Time Left = {0}; Velocity = {1}, Distance to Target = {2}",
                                time_left, _velocity_vector.magnitude, (end_pos - cur_pos).magnitude));

        if (time_left >= 0)
        {
            DataToExcel new_data = new DataToExcel(_velocity_vector.magnitude, _current_time);
            _excel_data.Add(new_data);
            WriteToExcel();
        }

        return(new_pos);
    }
Beispiel #5
0
        public IActionResult XunchaExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "巡查人", "巡查地点", "巡查时间", "情况上报", "状态", "联系电话"
                };
                var column2 = new List <string>()
                {
                    "XunchaInfoRen", "XunchaAddress", "XunchaTime", "QingkShangbao", "Staues", "FuzerPhone"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.XunchaInfo.Where(x => x.IsDeleted != 1 && parameters.Contains(x.XunchaInfoUuid.ToString())).Select(x => new
                    {
                        XunchaInfoRen = x.XunchaInfoRen,
                        XunchaAddress = x.XunchaAddress,
                        XunchaTime    = x.XunchaTime,
                        QingkShangbao = x.QingkShangbao,
                        Staues        = x.Staues,
                        FuzerPhone    = x.FuzerPhone
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "巡查记录信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";
                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:巡查信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.XunchaInfo.Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        XunchaInfoRen = x.XunchaInfoRen,
                        XunchaAddress = x.XunchaAddress,
                        XunchaTime    = x.XunchaTime,
                        QingkShangbao = x.QingkShangbao,
                        Staues        = x.Staues,
                        FuzerPhone    = x.FuzerPhone
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "巡查记录信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";
                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:巡查信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
        /// <summary>
        /// Myxls导出Excel,保存在客户端
        /// </summary>
        private void DataTableExportToExcel(long applyId, string xlsName, string sheetName)
        {
            //表头
            //决定Datatable显示哪些内容
            DataSet    ds = new DataSet();
            DataTable  dt = ds.Tables.Add("Sheet1");
            DataRow    dr;
            DataColumn column;

            //1---序号
            column            = new DataColumn();
            column.DataType   = System.Type.GetType("System.String");
            column.ColumnName = "序号";
            ds.Tables["Sheet1"].Columns.Add(column);

            //2---准考证号
            column            = new DataColumn();
            column.DataType   = System.Type.GetType("System.String");
            column.ColumnName = "准考证号";
            ds.Tables["Sheet1"].Columns.Add(column);
            //3---姓名
            column            = new DataColumn();
            column.DataType   = System.Type.GetType("System.String");
            column.ColumnName = "姓名";
            ds.Tables["Sheet1"].Columns.Add(column);
            //4---专业
            column            = new DataColumn();
            column.DataType   = System.Type.GetType("System.String");
            column.ColumnName = "专业";
            ds.Tables["Sheet1"].Columns.Add(column);

            var ml = new BLL.CCOM.Examination_arrangement_detail().GetModelList(" Ea_id='" + applyId + "' order by newid()");

            for (int row = 0; row < ml.Count; row++)
            {
                var m = ml[row];

                //申请人基本信息
                //学生用户
                try
                {
                    Model.CCOM.View_UserAgency model = new BLL.CCOM.View_UserAgency().GetModel(" User_id='" + m.User_id + "'");
                    dr    = ds.Tables["Sheet1"].NewRow();
                    dr[0] = row + 1;
                    dr[1] = model.UP_CCOM_number;
                    dr[2] = model.User_realname;
                    dr[3] = model.Agency_name;

                    ds.Tables["Sheet1"].Rows.Add(dr);
                }
                catch
                {
                    continue;
                }
            }

            //导出EXCEL,速度有点慢
            DataToExcel.ExportToExcel(ds, Server.MapPath("/upload/excel/"), xlsName + ".xlsx", this.Page);
        }
Beispiel #7
0
        public IActionResult RenyuzhuanyExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "需转移人员", "响应等级", "转移情况", "负责人", "负责人电话"
                };
                var column2 = new List <string>()
                {
                    "Xzhuanyi", "XiangyingDj", "ZhaunyiQingk", "Fuzeren", "FuzerenPhone"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.RenyuZhuany.Where(x => x.IsDeleted != 1 && parameters.Contains(x.RenyuZhuanyUuid.ToString())).Select(x => new
                    {
                        Xzhuanyi     = x.Xzhuanyi,
                        XiangyingDj  = x.XiangyingDj,
                        ZhaunyiQingk = x.ZhaunyiQingk,
                        Fuzeren      = x.Fuzeren,
                        FuzerenPhone = x.FuzerenPhone
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "人员转移信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:人员转移信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.RenyuZhuany.Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        Xzhuanyi     = x.Xzhuanyi,
                        XiangyingDj  = x.XiangyingDj,
                        ZhaunyiQingk = x.ZhaunyiQingk,
                        Fuzeren      = x.Fuzeren,
                        FuzerenPhone = x.FuzerenPhone
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "人员转移信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:人员转移信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
Beispiel #8
0
        public IActionResult ExportPass(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "姓名", "地点", "身份证号", "联系电话", "时间", "状态"
                };
                var column2 = new List <string>()
                {
                    "SecurityName", "SecurityAddress", "IdentityCard", "Phone", "SecurityTime", "SecurityStaues"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.Security.Where(x => x.IsDeleted != 1 && parameters.Contains(x.SecurityUuid.ToString())).Select(x => new Security
                    {
                        SecurityName    = x.SecurityName,
                        SecurityAddress = x.SecurityAddress,
                        IdentityCard    = x.IdentityCard,
                        Phone           = x.Phone,
                        SecurityTime    = x.SecurityTime,
                        SecurityStaues  = x.SecurityStaues,
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportBuidingExcel\\";
                    string uploadtitle    = "安防人员信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportBuidingExcel\\" + uploadtitle + ".xlsx");
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.Security.Where(x => x.IsDeleted != 1).Select(x => new Security
                    {
                        SecurityName    = x.SecurityName,
                        SecurityAddress = x.SecurityAddress,
                        IdentityCard    = x.IdentityCard,
                        Phone           = x.Phone,
                        SecurityTime    = x.SecurityTime,
                        SecurityStaues  = x.SecurityStaues,
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportBuidingExcel\\";
                    string uploadtitle    = "安防人员信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportBuidingExcel\\" + uploadtitle + ".xlsx");
                    return(Ok(response));
                }
            }
        }
Beispiel #9
0
        public static void Start()
        {
            List <VideoData> vdList = new List <VideoData>();

            ParseUrl(vdList, "http://search.kdnet.net/?q=%C5%ED%D6%DD%CA%AF%BB%AF&sa=%CB%D1%CB%F7&category=title&boardid=0&arrival=2013-12-29&departure=2016-12-29");

            DataToExcel.CreateExcel("凯迪社区", vdList);
        }
        public static void Start()
        {
            List <VideoData> vdList = new List <VideoData>();

            ParseUrl(vdList, "http://search.home.news.cn/forumbookSearch.do?sw=%E5%BD%AD%E5%B7%9E%E7%9F%B3%E5%8C%96&srchType=1");

            DataToExcel.CreateExcel("发展论坛", vdList);
        }
Beispiel #11
0
        public static void Start()
        {
            List <VideoData> vdList = new List <VideoData>();

            ParseUrl(vdList, "http://bbs1.people.com.cn/quickSearch.do?field=title&threadtype=1&content=%E5%BD%AD%E5%B7%9E%E7%9F%B3%E5%8C%96");

            DataToExcel.CreateExcel("强国论坛", vdList);
        }
Beispiel #12
0
        public IActionResult UAVExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "无人机名称", "无人机编号", "链接地址", "无人机监控地址"
                };
                var column2 = new List <string>()
                {
                    "UAVName", "UAVNumber", "UAVUrl", "UAVAddress"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.Uav.Where(x => x.IsDeleted != 1 && parameters.Contains(x.Uavuuid.ToString())).Select(x => new
                    {
                        UAVName    = x.Uavname,
                        UAVNumber  = x.Uavnumber,
                        UAVUrl     = x.Uavurl,
                        UAVAddress = x.Uavaddress
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "无人机信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:无人机信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.Uav.Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        UAVName    = x.Uavname,
                        UAVNumber  = x.Uavnumber,
                        UAVUrl     = x.Uavurl,
                        UAVAddress = x.Uavaddress
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "无人机信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:无人机信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
        public IActionResult RescueTeamExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "队名", "小队人数", "队长", "联系电话"
                };
                var column2 = new List <string>()
                {
                    "TeamName", "TeamRenshu", "TeamCaptain", "TeamPhone"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.RescueTeam.Where(x => x.IsDeleted != 1 && parameters.Contains(x.RescueTeamUuid.ToString())).Select(x => new
                    {
                        TeamName    = x.TeamName,
                        TeamRenshu  = x.TeamRenshu,
                        TeamCaptain = x.TeamCaptain,
                        TeamPhone   = x.TeamPhone,
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "救援小队信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:救援小队信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.RescueTeam.Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        TeamName    = x.TeamName,
                        TeamRenshu  = x.TeamRenshu,
                        TeamCaptain = x.TeamCaptain,
                        TeamPhone   = x.TeamPhone,
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "救援小队信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:救援小队信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
        public IActionResult VillageMemberExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "村庄名称", "姓名", "性别", "联系电话"
                };
                var column2 = new List <string>()
                {
                    "VillageName", "MemberName", "MemberSex", "MemberPhone"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.VillageMember.Where(x => x.IsDelete != 1 && parameters.Contains(x.VillageMemberUuid.ToString())).Select(x => new
                    {
                        VillageName = x.VillageUu.VillageName,
                        MemberName  = x.MemberName,
                        MemberSex   = x.MemberSex,
                        MemberPhone = x.MemberPhone
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "村庄成员信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:村干部信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.VillageMember.Where(x => x.IsDelete != 1).Select(x => new
                    {
                        VillageName = x.VillageUu.VillageName,
                        MemberName  = x.MemberName,
                        MemberSex   = x.MemberSex,
                        MemberPhone = x.MemberPhone
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "村庄成员信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:村干部信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
Beispiel #15
0
        public static void Start()
        {
            List <VideoData> vdList = new List <VideoData>();

            for (int i = 1; i < 76; i++)
            {
                ParseUrl(vdList, "http://search.tianya.cn/bbs?q=%E5%BD%AD%E5%B7%9E%E7%9F%B3%E5%8C%96&pn=" + i);
            }
            DataToExcel.CreateExcel("天涯论坛", vdList);
        }
Beispiel #16
0
        public static void Start()
        {
            List <VideoData> vdList = new List <VideoData>();

            for (int i = 1; i < 2; i++)
            {
                ParseUrl(vdList, "http://search.mop.com/cse/search?q=%E5%BD%AD%E5%B7%9E%E7%9F%B3%E5%8C%96&click=" + i + "&s=10030666497398670337&nsid=");
            }
            DataToExcel.CreateExcel("猫扑社区", vdList);
        }
Beispiel #17
0
        /// <summary>
        /// 导出数据
        /// </summary>
        protected override void DoExport(object sender)
        {
            DataTable dt = new DataTable();

            int[] rows = _SummaryView.GetSelectedRows();
            if (rows.Length < 1)
            {
                Msg.Warning("请选择至少1条数据!");
                return;
            }
            else
            {
                WaiteServer.ShowWaite(this);

                int sucess = 0;

                Dictionary <string, object> dic = new Dictionary <string, object>();

                if (!String.IsNullOrEmpty(txts_RETURN_STATUS.Text))
                {
                    dic.Add("RETURN_STATUS", txts_RETURN_STATUS.EditValue);
                }
                if (!String.IsNullOrEmpty(txts_STAR_TIME.Text))
                {
                    dic.Add("STAR_TIME", txts_STAR_TIME.EditValue);
                }
                if (!String.IsNullOrEmpty(txts_END_TIME.Text))
                {
                    dic.Add("END_TIME", txts_END_TIME.EditValue);
                }

                foreach (int k in rows)
                {
                    string Key = ConvertEx.ToString(_SummaryView.GetDataRow(k)[_bll.SummaryModel.PrimaryKey]);

                    if (!String.IsNullOrEmpty(Key))
                    {
                        dic.Add("G_NAME" + sucess.ToString(), ",'" + Key + "'");
                    }

                    sucess++;
                }

                dt = bll.GetListData(dic);//获得需要绑定的数据
            }

            if (DataToExcel.ExportToExcel(dt, "商品汇总", Lists))
            {
                WaiteServer.CloseWaite();
                Msg.ShowInformation("导出成功!");
            }

            WaiteServer.CloseWaite();
        }
        internal static void DownLoadTemplateFile()
        {
            var            excelPackage   = DataToExcel.CreateEmptyTemplate();
            SaveFileDialog saveFileDialog = new();

            saveFileDialog.Filter      = "xlsx files (*.xlsx)|*.xlsx|xls files (*.xls)|*.xls";
            saveFileDialog.FilterIndex = 1;
            if (saveFileDialog.ShowDialog() == true)
            {
                FileInfo fi = new FileInfo(saveFileDialog.FileName);
                excelPackage.SaveAs(fi);
            }
        }
Beispiel #19
0
        private void MyExcel()
        {
            DataSet ds = new lgk.BLL.tb_bonus().GetListByUser(getWhere2());//获取所有时间段的奖金信息

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string FilePath = Server.MapPath("/userfiles/");// +"\\" + ExcelFolder + "\\";
                if (!Directory.Exists(FilePath))
                {
                    Directory.CreateDirectory(FilePath);
                }
                //生成列的中文对应表
                Hashtable nameList = new Hashtable();
                nameList.Add("UserCode", "用户名");
                nameList.Add("sf", "应发奖金");
                nameList.Add("BankAccountUser", "开户姓名");
                nameList.Add("BankName", "开户行");
                nameList.Add("BankAccount", "卡号");
                nameList.Add("BankBranch", "支行名称");

                //利用excel对象
                DataToExcel dte      = new DataToExcel();
                string      filename = "";
                try
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        filename = dte.DataExcel(ds.Tables[0], "奖金", FilePath, nameList);
                    }
                }
                catch
                {
                    //dte.KillExcelProcess();
                }

                if (filename != "")
                {
                    string path = FilePath + filename;
                    Response.Redirect("/userfiles/" + filename, true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('当前无数据导出!');", true);
            }
        }
        private void ToExcel()
        {
            if (Session["DataTables"] == null)
            {
                this.RegisterStartupScript("无结果", "<script>alert('请先进行统计!');</script>");
                return;
            }

            Dictionary <string, DataTable> dataTables = Session["DataTables"] as Dictionary <string, DataTable>;

            if (dataTables == null)
            {
                this.RegisterStartupScript("无结果", "<script>alert('请先进行统计!');</script>");
                return;
            }
            DataToExcel dte = new DataToExcel();

            dte.DataGridViewToExcel(dataTables);
        }
        public ActionResult getExcel(string cols, string data)
        {
            DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject <DataTable>(cols);
            List <Dictionary <string, object> > list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(data);
            DataToExcel converter = new DataToExcel();
            var         bytes     = converter.tOExcel(dt, list);

            //return new FileStreamResult(stream, "application/x-xls");


            Response.Charset     = "UTF-8";
            Response.ContentType = "application/octet-stream";
            //Response.ContentEncoding = encoding;
            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("导出.xls", System.Text.Encoding.UTF8));
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
            return(new EmptyResult());
        }
        public ActionResult getExcelServer(string modelID, string keyword, string filter, string order, bool isCustom, string cols, string formstate)
        {
            try
            {
                // var data = this._service.getModelTreeDataALL(modelID, keyword, filter, order);
                DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject <DataTable>(cols);

                var dict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(formstate);
                List <Dictionary <string, object> > data;
                if (isCustom)
                {
                    data = this._serviceCutomDS.getModelTreeDataALL(modelID, keyword, filter, order, dict);
                }
                else
                {
                    data = this._service.getModelTreeDataALL(modelID, keyword, filter, order);
                }

                DataToExcel converter = new DataToExcel();
                var         bytes     = converter.tOExcel(dt, data);


                Response.Charset     = "UTF-8";
                Response.ContentType = "application/octet-stream";
                //Response.ContentEncoding = encoding;
                Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("导出.xls", System.Text.Encoding.UTF8));
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
                return(new EmptyResult());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IActionResult HeDaowaterExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "地址", "时间", "水位", "临界点", "水位预警", "防汛等级"
                };
                var column2 = new List <string>()
                {
                    "HeDaowaterAddress", "HeDaowaterTime", "HeDaoHeDaowaterSw", "Ljiedian", "HeDaowaterYujin", "FangxunDj"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.HeDaowater.Where(x => x.IsDeleted != 1 && parameters.Contains(x.HeDaowaterUuid.ToString())).Select(x => new
                    {
                        HeDaowaterAddress = x.HeDaowaterAddress,
                        HeDaowaterTime    = x.HeDaowaterTime,
                        HeDaoHeDaowaterSw = x.HeDaoHeDaowaterSw,
                        Ljiedian          = x.Ljiedian,
                        HeDaowaterYujin   = x.HeDaowaterYujin,
                        FangxunDj         = x.FangxunDj,
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "河道水位信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:河道水位监测信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.HeDaowater.Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        HeDaowaterAddress = x.HeDaowaterAddress,
                        HeDaowaterTime    = x.HeDaowaterTime,
                        HeDaoHeDaowaterSw = x.HeDaoHeDaowaterSw,
                        Ljiedian          = x.Ljiedian,
                        HeDaowaterYujin   = x.HeDaowaterYujin,
                        FangxunDj         = x.FangxunDj,
                    }).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportEmergencyExcel\\";
                    string uploadtitle    = "河道水位信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportEmergencyExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:河道水位监测信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
Beispiel #24
0
        protected void exportexcel_ServerClick(object sender, EventArgs e)
        {
            string order    = "AEE_score DESC, AEE_sequence DESC ,UP_CCOM_number asc";
            string strWhere = CombSqlTxt(this.keywords);

            try
            {
                string order1    = "";
                string strWhere1 = " Major_Agency_id=" + major_id + " AND Period_id=" + period_id + " AND Subject_level=2";

                subList = new BLL.CCOM.Subject().GetModelList(strWhere1 + order1);
                count   = subList.Count;

                BLL.CCOM.View_AEE_Score          bll       = new BLL.CCOM.View_AEE_Score();
                List <Model.CCOM.View_AEE_Score> modelList = bll.GetModelList(strWhere + " order by " + order);

                DataSet _ds = new DataSet();
                _ds.Tables.Clear();

                DataTable  dt = _ds.Tables.Add("Sheet1");
                DataRow    dr;
                DataColumn column;

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "序号";
                _ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "考生号";
                _ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "姓名";
                _ds.Tables["Sheet1"].Columns.Add(column);

                if (count > 0)
                {
                    foreach (var model in subList)
                    {
                        column            = new DataColumn();
                        column.DataType   = System.Type.GetType("System.String");
                        column.ColumnName = model.Subject_title;
                        _ds.Tables["Sheet1"].Columns.Add(column);

                        column            = new DataColumn();
                        column.DataType   = System.Type.GetType("System.String");
                        column.ColumnName = model.Subject_title + "序";
                        _ds.Tables["Sheet1"].Columns.Add(column);
                    }
                }

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "总成绩";
                _ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "总平均序";
                _ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "专业排名";
                _ds.Tables["Sheet1"].Columns.Add(column);

                int _count = modelList.Count;
                for (int i = 0, num = 1; i < _count; i++, num++)
                {
                    dr        = _ds.Tables["Sheet1"].NewRow();
                    dr["序号"]  = num.ToString();
                    dr["姓名"]  = modelList[i].User_realname;
                    dr["考生号"] = modelList[i].UP_CCOM_number;

                    int t = 0;
                    if (count > 0)
                    {
                        foreach (var model in subList)
                        {
                            dr[3 + t]     = getSubjectAverageScore(modelList[i].User_id.ToString(), model.Subject_id.ToString());
                            dr[3 + t + 1] = getSubjectAverageXu(modelList[i].User_id.ToString(), model.Subject_id.ToString());
                            t            += 2;
                        }
                    }

                    dr["总成绩"]  = ((decimal)(modelList[i].AEE_score)).ToString("F2");
                    dr["总平均序"] = ((decimal)modelList[i].AEE_sequence).ToString("F2");
                    dr["专业排名"] = modelList[i].AEE_ranking;

                    _ds.Tables["Sheet1"].Rows.Add(dr);
                }
                DataToExcel.ExportToExcel(_ds, Server.MapPath("/upload/excel/"), "艺考科目成绩_" + DateTime.Now.ToFileTime().ToString() + ".xlsx", this.Page);
            }
            catch
            {
                JscriptMsg("获取艺考科目成绩出错", "", "Error");
            }
        }
        protected void exportexcel_ServerClick(object sender, EventArgs e)
        {
            string order    = "UP_CCOM_number asc";
            string strWhere = CombSqlTxt(this.keywords);

            try
            {
                BLL.CCOM.View_AEE_Subject_Score bll = new BLL.CCOM.View_AEE_Subject_Score();

                List <Model.CCOM.View_AEE_Subject_Score> modelList = bll.GetModelList(strWhere + " order by " + order);

                DataSet ds = new DataSet();
                ds.Tables.Clear();

                DataTable  dt = ds.Tables.Add("Sheet1");
                DataRow    dr;
                DataColumn column;

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "序号";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "考生号";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "姓名";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "科目名称";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "科目成绩";
                ds.Tables["Sheet1"].Columns.Add(column);

                int count = modelList.Count;
                for (int i = 0, num = 1; i < count; i++, num++)
                {
                    dr         = ds.Tables["Sheet1"].NewRow();
                    dr["序号"]   = num.ToString();
                    dr["姓名"]   = modelList[i].User_realname;
                    dr["考生号"]  = modelList[i].UP_CCOM_number;
                    dr["科目名称"] = getSubjectName(modelList[i].Subject_id.ToString());


                    string score = getSubjectScore(modelList[i].User_id.ToString(), modelList[i].Subject_id.ToString(), this.judge_id.ToString());
                    if (score != null && score != "")
                    {
                        dr["科目成绩"] = score;
                    }
                    ds.Tables["Sheet1"].Rows.Add(dr);
                }

                DataToExcel.ExportToExcel(ds, Server.MapPath("/upload/excel/"), "考生科目成绩_" + DateTime.Now.ToFileTime().ToString() + ".xlsx", this.Page);
            }
            catch
            {
                JscriptMsg("获取考生科目成绩出错", "", "Error");
            }
        }
Beispiel #26
0
        public IActionResult ParkingLotExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "名称", "位置", "总车位", "已用车位", "剩余车位", "经度", "纬度"
                };
                var column2 = new List <string>()
                {
                    "ParkingLotName", "ParkingLotAddress", "Zchewei", "Ychewei", "Schewei", "Lon", "Lat"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query1 = _dbContext.ParkingLot.Where(x => x.IsDeleted != 1 && parameters.Contains(x.ParkingLotUuid.ToString())).Select(x => new
                    {
                        Id                = x.Id,
                        ParkingLotName    = x.ParkingLotName,
                        ParkingLotAddress = x.ParkingLotAddress,
                        Zchewei           = x.Zchewei,
                        Ychewei           = x.Ychewei,
                        Schewei           = x.Schewei,
                        ParkingLotsru     = x.ParkingLotsru,
                        Lon               = x.Lon,
                        Lat               = x.Lat,
                    });
                    var    query          = query1.OrderByDescending(x => x.Id).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportIntelligenttravelExcel\\";
                    string uploadtitle    = "停车场信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportIntelligenttravelExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:停车场信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query1 = _dbContext.ParkingLot.Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        Id                = x.Id,
                        ParkingLotName    = x.ParkingLotName,
                        ParkingLotAddress = x.ParkingLotAddress,
                        Zchewei           = x.Zchewei,
                        Ychewei           = x.Ychewei,
                        Schewei           = x.Schewei,
                        ParkingLotsru     = x.ParkingLotsru,
                        Lon               = x.Lon,
                        Lat               = x.Lat,
                    });
                    var    query          = query1.OrderByDescending(x => x.Id).ToList();
                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportIntelligenttravelExcel\\";
                    string uploadtitle    = "停车场信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportIntelligenttravelExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:停车场信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
Beispiel #27
0
        private void MyExcel()
        {
            DataSet ds = GetAgentList(getWhere2());//获取信息

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string FilePath = Server.MapPath("/userfiles/");// +"\\" + ExcelFolder + "\\";
                if (!Directory.Exists(FilePath))
                {
                    Directory.CreateDirectory(FilePath);
                }
                //生成列的中文对应表
                Hashtable nameList = new Hashtable();
                nameList.Add("AgentCode", "代理中心编号");
                nameList.Add("UserCode", "会员编号");
                nameList.Add("TrueName", "会员姓名");
                nameList.Add("LevelName", "会员级别");
                nameList.Add("Quyu", "代理区域");
                nameList.Add("AppliTime", "申请日期");
                nameList.Add("OpenTime", "确认日期");

                DataTable dt = ds.Tables[0];
                dt.Columns.Remove("ID");
                dt.Columns.Remove("AgentType");
                dt.Columns.Remove("Flag");
                dt.Columns.Remove("UserID");
                dt.Columns.Remove("LevelID");
                dt.Columns.Remove("AgentsID");
                dt.Columns.Remove("User006");

                DataTable  newTable = new DataTable();
                DataColumn newCol   = new DataColumn();
                newCol.ColumnName = "Quyu";
                newTable.Columns.Add(newCol);

                foreach (DataColumn col in dt.Columns)
                {
                    DataColumn c = new DataColumn();
                    c.ColumnName = col.ColumnName;
                    newTable.Columns.Add(c);
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = newTable.NewRow();
                    dr["Quyu"] = dt.Rows[i]["AgentInProvince"].ToString() + dt.Rows[i]["AgentInCity"].ToString() + dt.Rows[i]["AgentAddress"].ToString();
                    foreach (DataColumn ncol in dt.Columns)
                    {
                        dr[ncol.ColumnName] = dt.Rows[i][ncol.ColumnName];
                    }
                    newTable.Rows.Add(dr);
                }
                newTable.Columns.Remove("AgentInProvince");
                newTable.Columns.Remove("AgentInCity");
                newTable.Columns.Remove("AgentAddress");
                //利用excel对象
                DataToExcel dte      = new DataToExcel();
                string      filename = "";
                try
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        filename = dte.DataExcel(newTable, "已开通代理中心", FilePath, nameList);
                    }
                }
                catch
                {
                    //dte.KillExcelProcess();
                }

                if (filename != "")
                {
                    string path = FilePath + filename;
                    Response.Redirect("/userfiles/" + filename, true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('当前无数据导出!');", true);
            }
        }
        public IActionResult GtoiletExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "名称", "位置", "经度", "纬度", "使用情况", "空气质量", "水量预警"
                };
                var column2 = new List <string>()
                {
                    "GtoiletName", "GtoiletAddress", "Lon", "Lat", "GtoiletStaues", "KongqiZhil", "WaterYujin"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.Gtoilet.Where(x => x.IsDeleted != 1 && parameters.Contains(x.GtoiletUuid.ToString())).Select(x => new
                    {
                        GtoiletName    = x.GtoiletName,
                        GtoiletAddress = x.GtoiletAddress,
                        Lon            = x.Lon,
                        Lat            = x.Lat,
                        GtoiletStaues  = x.GtoiletStaues,
                        KongqiZhil     = x.KongqiZhil,
                        WaterYujin     = x.WaterYujin
                    }).ToList();



                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportIntelligenttravelExcel\\";
                    string uploadtitle    = "3A公厕信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportIntelligenttravelExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:3A公厕信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.Gtoilet.Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        GtoiletName    = x.GtoiletName,
                        GtoiletAddress = x.GtoiletAddress,
                        Lon            = x.Lon,
                        Lat            = x.Lat,
                        GtoiletStaues  = x.GtoiletStaues,
                        KongqiZhil     = x.KongqiZhil,
                        WaterYujin     = x.WaterYujin
                    }).ToList();



                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportIntelligenttravelExcel\\";
                    string uploadtitle    = "3A公厕信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportIntelligenttravelExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:3A公厕信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
        public IActionResult XlProjectExport(string ids)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var column = new List <string>()
                {
                    "设备ID", "设备类型", "位置", "经度", "纬度", "管理人信息", "设备状态"
                };
                var column2 = new List <string>()
                {
                    "XlShebeiId", "XlShebeiType", "ShebeiAddress", "Lon", "Lat", "AdminInfo", "ShebeiType"
                };
                if (!string.IsNullOrEmpty(ids))
                {
                    var parameters = ids.Trim().Split(",");
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        parameters[i] = parameters[i].ToUpper();
                    }
                    var query = _dbContext.XlProject.OrderByDescending(x => x.Id).Where(x => x.IsDeleted != 1 && parameters.Contains(x.XlProjectUuid.ToString())).Select(x => new
                    {
                        XlShebeiId    = x.XlShebeiId,
                        XlShebeiType  = x.XlShebeiType,
                        ShebeiAddress = x.ShebeiAddress,
                        Lon           = x.Lon,
                        Lat           = x.Lat,

                        AdminInfo  = x.AdminInfo,
                        ShebeiType = x.ShebeiType
                    }).ToList();



                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportSocialGovernExcel\\";
                    string uploadtitle    = "雪亮工程信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportSocialGovernExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:雪亮工程信息数据", _dbContext);
                    return(Ok(response));
                }
                else
                {
                    var query = _dbContext.XlProject.OrderByDescending(x => x.Id).Where(x => x.IsDeleted != 1).Select(x => new
                    {
                        XlShebeiId    = x.XlShebeiId,
                        XlShebeiType  = x.XlShebeiType,
                        ShebeiAddress = x.ShebeiAddress,
                        Lon           = x.Lon,
                        Lat           = x.Lat,

                        AdminInfo  = x.AdminInfo,
                        ShebeiType = x.ShebeiType
                    }).ToList();



                    string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportSocialGovernExcel\\";
                    string uploadtitle    = "雪亮工程信息导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string sFileName      = $"{sWebRootFolder + uploadtitle}.xlsx";

                    DataToExcel.TablesToExcel(query, sFileName, column, column2);
                    response.SetData("\\UploadFiles\\ImportSocialGovernExcel\\" + uploadtitle + ".xlsx");
                    ToLog.AddLog("导出", "成功:导出:雪亮工程信息数据", _dbContext);
                    return(Ok(response));
                }
            }
        }
Beispiel #30
0
        public static void ExportToExcel(DataSet ds, Hashtable displaycol_nameList, string otherInfo)
        {
            common_file.common_app.get_czsj();

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                string    filePath     = "";
                string    fileName     = "";
                string    get_fileName = "";
                Hashtable nameList     = new Hashtable();
                nameList = displaycol_nameList;
                SaveFileDialog      saveFileDialog1;
                FolderBrowserDialog folderBrowserDialog1;
                //利用excel对象
                DataToExcel dte = new DataToExcel();
                try
                {
                    common_file.common_app.get_czsj();

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        common_file.common_app.get_czsj();

                        saveFileDialog1        = new SaveFileDialog();
                        saveFileDialog1.Filter = "Excel files (*.xls)|*.xls";

                        folderBrowserDialog1 = new FolderBrowserDialog();
                        if (defaulPath.Trim() != "")
                        {
                            folderBrowserDialog1.SelectedPath = defaulPath;
                        }
                        if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                        {
                            common_file.common_app.get_czsj();

                            filePath     = folderBrowserDialog1.SelectedPath + "\\";
                            defaulPath   = folderBrowserDialog1.SelectedPath;
                            get_fileName = dte.DataExcel(ds.Tables[0], otherInfo, filePath, nameList).Trim();
                            if (get_fileName != "")
                            {
                                fileName = filePath + get_fileName;
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
                catch
                {
                    dte.KillExcelProcess();
                }

                if (get_fileName.Trim() != "")
                {
                    common_file.common_app.get_czsj();

                    common_file.common_app.Message_box_show(common_file.common_app.message_title, "导出成功!");
                    //Response.Redirect((ExcelFolder+"\\"+filename,true);
                    //StreamWriter aWriter = new StreamWriter(fileName); aWriter.Write(fileName); aWriter.Close();
                }
            }
            Cursor.Current = Cursors.Default;
        }