//导出Excel protected void btn_Export_Click(object sender, EventArgs e) { string yearAndMonth = string.Empty; if (!string.IsNullOrEmpty(txt_StartTime.Text)) { yearAndMonth = DateTime.Parse(txt_StartTime.Text).ToString("yyyy-MM"); } else if (!string.IsNullOrEmpty(txt_YearAndMonth.Text)) { yearAndMonth = DateTime.Parse(txt_YearAndMonth.Text).ToString("yyyy-MM"); } if (!string.IsNullOrEmpty(yearAndMonth)) { GridDataBind(); RG_GrossProfit.DataBind(); string fileName = string.Format("{0}公司毛利详细", yearAndMonth); fileName = Server.UrlEncode(fileName); RG_GrossProfit.ExportSettings.ExportOnlyData = true; RG_GrossProfit.HorizontalAlign = HorizontalAlign.Right; RG_GrossProfit.ExportSettings.IgnorePaging = true; RG_GrossProfit.ExportSettings.FileName = fileName; RG_GrossProfit.MasterTableView.ExportToExcel(); } }
//查询 protected void btn_Search_Click(object sender, EventArgs e) { GridDataBind(); RG_GrossProfit.CurrentPageIndex = 0; RG_GrossProfit.DataBind(); }