Exemple #1
0
        public ActionResult TaskConfigList(DataPage dp)
        {
            List <TaskConfig> lists = new List <TaskConfig>();

            if (Request["btnExportExcel"] == null)//导出Excel
            {
                lists = PetFeedEventsBll.GetTaskConfig(ref dp);
                GetDataPage(dp);
            }
            else
            {
                dp.PageSize = 0;
                lists       = PetFeedEventsBll.GetTaskConfig(ref dp);
                string fileName = "nothing";
                if (lists.Count() > 0)
                {
                    fileName = "TaskConfigList" + lists.Count() + "_Item";
                }
                Dictionary <string, Func <TaskConfig, string> > showFields = new Dictionary <string, Func <TaskConfig, string> >();
                showFields.Add("TaskConfigId", z => "'" + z.TaskConfigId.ToString());
                showFields.Add("TaskName", z => "'" + z.TaskName.ToString());
                showFields.Add("TaskDesc", z => "'" + z.TaskDesc.ToString());
                showFields.Add("PacketId", z => "'" + z.PacketId.ToString());
                showFields.Add("ItemCode", z => "'" + z.ItemCode.ToString());
                showFields.Add("ItemTimePerTask", z => "'" + z.ItemTimePerTask.ToString());
                showFields.Add("ItemCountPerTask", z => "'" + z.ItemCountPerTask.ToString());
                showFields.Add("GoldPerTask", z => "'" + z.GoldPerTask.ToString());
                showFields.Add("BindCashPerTask", z => "'" + z.BindCashPerTask.ToString());
                showFields.Add("Source", z => "'" + z.Source.ToString());
                ExcelHelper2 <TaskConfig> elh = new ExcelHelper2 <TaskConfig>(lists, null, showFields);
                elh.FileWebSaveAs(Response, fileName);
            }
            return(View(lists));
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            var       fileName = AppDomain.CurrentDomain.BaseDirectory + "testDemo001.xls";
            DataTable dt       = ExcelHelper2.ExcelToDataTable("", true, fileName);

            DataRow[] dataRows = dt.Select("col1 = '10' and col2 = '11'");
            MessageBox.Show(dataRows.Length + "");
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("col1");
            dt.Columns.Add("col2");
            dt.Columns.Add("col3");

            for (int i = 0; i < 10; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = "col1_" + i;
                dr[1] = "col2_" + i;
                dr[2] = "col3_" + i;
                dt.Rows.Add(dr);
            }
            var fileName = AppDomain.CurrentDomain.BaseDirectory + "testDemo001.xls";

            ExcelHelper2.DataTableToExcel(dt, "data", false, fileName, true);
        }
Exemple #4
0
        public ActionResult DynamicPacketQueueLogList(DataPage dp, DynamicPacketQueueLog model)
        {
            model.GUID       = Guid.Empty;
            model.CreateTime = defaultDate;
            List <DynamicPacketQueueLog> lists = new List <DynamicPacketQueueLog>();

            if (Request["btnExportExcel"] == null)//导出Excel
            {
                lists = PetFeedEventsBll.GetDynamicPacketQueueLogList(ref dp, model);
                GetDataPage(dp);
            }
            else
            {
                dp.PageSize = 0;
                lists       = PetFeedEventsBll.GetDynamicPacketQueueLogList(ref dp, model);
                string fileName = "nothing";
                if (lists.Count() > 0)
                {
                    fileName = "DynamicPacketQueueLogList" + lists.Count() + "_Item";
                }
                Dictionary <string, Func <DynamicPacketQueueLog, string> > showFields = new Dictionary <string, Func <DynamicPacketQueueLog, string> >();
                showFields.Add("LogId", z => "'" + z.LogId.ToString());
                showFields.Add("PacketId", z => "'" + z.PacketId.ToString());
                showFields.Add("AvatarId", z => "'" + z.AvatarId.ToString());
                showFields.Add("Sex", z => "'" + z.Sex.ToString());
                showFields.Add("Site", z => "'" + z.Site.ToString());
                showFields.Add("UserId", z => "'" + z.UserId.ToString());
                showFields.Add("ItemCode", z => "'" + z.ItemCode.ToString());
                showFields.Add("PacketItemTime", z => "'" + z.PacketItemTime.ToString());
                showFields.Add("PacketItemCount", z => "'" + z.PacketItemCount.ToString());
                showFields.Add("CreateTime", z => "'" + z.CreateTime.ToString());
                showFields.Add("Source", z => "'" + z.Source.ToString());
                showFields.Add("GUID", z => "'" + z.GUID.ToString());
                showFields.Add("Gold", z => "'" + z.Gold.ToString());
                showFields.Add("BindCash", z => "'" + z.BindCash.ToString());
                ExcelHelper2 <DynamicPacketQueueLog> elh = new ExcelHelper2 <DynamicPacketQueueLog>(lists, null, showFields);
                elh.FileWebSaveAs(Response, fileName);
            }
            return(View(lists));
        }
Exemple #5
0
        public ActionResult GameDailyLogList(DataPage dp, DateTime?RecordDate, GameDailyLog model)
        {
            model.GUID       = Guid.Empty;
            model.RecordDate = RecordDate ?? DateTime.Now.AddDays(-1);
            model.CreateTime = defaultDate;
            List <GameDailyLog> lists = new List <GameDailyLog>();

            if (Request["btnExportExcel"] == null)//导出Excel
            {
                lists = PetFeedEventsBll.GetGameDailyLogList(ref dp, model);
                GetDataPage(dp);
            }
            else
            {
                dp.PageSize = 0;
                lists       = PetFeedEventsBll.GetGameDailyLogList(ref dp, model);
                string fileName = "nothing";
                if (lists.Count() > 0)
                {
                    fileName = "GameDailyLogList" + lists.Count() + "_Item";
                }
                Dictionary <string, Func <GameDailyLog, string> > showFields = new Dictionary <string, Func <GameDailyLog, string> >();
                showFields.Add("RecordId", z => "'" + z.RecordId.ToString());
                showFields.Add("UserId", z => "'" + z.UserId.ToString());
                showFields.Add("AreaId", z => "'" + z.AreaId.ToString());
                showFields.Add("AvatarId", z => "'" + z.AvatarId.ToString());
                showFields.Add("AvatarName", z => "'" + z.AvatarName.ToString());
                showFields.Add("Sex", z => "'" + z.Sex.ToString());
                showFields.Add("RecordDate", z => "'" + z.RecordDate.ToString());
                showFields.Add("TaskConfigId", z => "'" + z.TaskConfigId.ToString());
                showFields.Add("ActualNum", z => "'" + z.ActualNum.ToString());
                showFields.Add("FinalGetNum", z => "'" + z.FinalGetNum.ToString());
                showFields.Add("CreateTime", z => "'" + z.CreateTime.ToString());
                showFields.Add("GUID", z => "'" + z.GUID.ToString());
                showFields.Add("Source", z => "'" + z.Source.ToString());
                ExcelHelper2 <GameDailyLog> elh = new ExcelHelper2 <GameDailyLog>(lists, null, showFields);
                elh.FileWebSaveAs(Response, fileName);
            }
            return(View(lists));
        }